This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to use user Defined separator in JPopupMenu instead of  addSeparator() provided by Java  Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to use user Defined separator in JPopupMenu instead of  addSeparator() provided by Java  Swing" Watch "How to use user Defined separator in JPopupMenu instead of  addSeparator() provided by Java  Swing" New topic
Author

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

Renjith mohanan
Ranch Hand

Joined: Jun 19, 2009
Posts: 52
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


Personal E-mail: kalliyoorrenjith@gmail.com
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

What's wrong with the default separator?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Renjith mohanan
Ranch Hand

Joined: Jun 19, 2009
Posts: 52
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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Jun 19, 2009
Posts: 52
Thanks very much Michael ,

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


Thanks again, Michael..>
 
Don't get me started about those stupid light bulbs.
 
subject: How to use user Defined separator in JPopupMenu instead of addSeparator() provided by Java Swing
 
Similar Threads
Draw line in panel
Using JCheckBox as CellRenderer in JComboBox
How add JLabels as headers for JPopupMenu's menuitem sections?
JMenuItem centering
getting exact url