Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use user Defined separator in JPopupMenu instead of addSeparator() provided by Java Swing

 
Renjith mohanan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a JPopupMenu (popup) and then I insert the method (popup.addSeparator()) after each MenuITem in the popup.
Is there any way to define our own separator, and use the separator instead of the method addSeparator()

Thanks In Advance

Renjith M
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's wrong with the default separator?
 
Renjith mohanan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

Thanks for your time.

The default separator is continuous line.
I am developing a touch screen system with Java Swing, so I need to increase the look and feel of the system.
For that purpose, I need to place a dotted black arrow (like this -----------------------------) as the separator.
Is there any way to override the method(I don't know, which method to override) to display the dotted black arrow as the separator.

Thanks
Renjith M
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try something like this



the 'x < 150' you'd need to decide what goes here,
- the exact width of the popup
- a magic number wider than the popup
- whether the last line is flush to the edge etc
 
Renjith mohanan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much Michael ,

I used your code and set black color to the Graphics g.
The code is like this


Thanks again, Michael..>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic