Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class PopupMenuAlignment

java.lang.Object
  com.wordpress.tipsforjava.swing.PopupMenuAlignment
All Implemented Interfaces:
ContainerListener

public class PopupMenuAlignment
extends Object

Convenience class to align the text of JMenuItems within a specified JPopupMenu to be either CENTER or TRAILING aligned. The default for trailing would be right aligned unless the component orientation is changed. The class can be used in one of two ways. For a static popup menu you can just invoke the statick alignText() method once the menu has been created. For dynamic popup menus you can use this class as a ContainerListener on the popup menu so as menu items are added or removed the remaining items are adjusted accordingly.

Authors:
Rob Camick
Darryl Burke


Field Summary
static int CENTER

static int TRAILING

private int alignment

 
Constructor Summary
PopupMenuAlignment(int alignment)

Use this class as a listener to handle dynamic changes to the popup menu.

 
Method Summary
static void alignText(JPopupMenu popup, int alignment)

Align the menu items contained with the popup menu.

void componentAdded(ContainerEvent e)

void componentRemoved(ContainerEvent e)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

CENTER

public static int CENTER


TRAILING

public static int TRAILING


alignment

private int alignment


 
Constructor Detail

PopupMenuAlignment

public PopupMenuAlignment(int alignment)
Use this class as a listener to handle dynamic changes to the popup menu.
Parameters:
alignment - alignment of each menu item. Either CENTER or TRAILING


 
Method Detail

alignText

public static void alignText(JPopupMenu popup, int alignment)
Align the menu items contained with the popup menu.
Parameters:
popup - the popup menu
alignment - alignment of each menu item. Either CENTER or TRAILING


componentAdded

public void componentAdded(ContainerEvent e)


componentRemoved

public void componentRemoved(ContainerEvent e)


 

Groovy Documentation