Donnerstag, 15. November 2007

How to change the selectionColor of a JMenuItem

So you just created some colored JMenuItems, but you are unsatisfied, that everytime you move your mouse over the MenuItem, the nice color is changed to an ugly blue.

Use this MenuItemUI:

class myMenuItemUI extends BasicMenuItemUI{
public myMenuItemUI(Color c){
super();
this.selectionBackground = c;
}
}


Usage:
myMenuItem.setUI(new myMenuItemUI(Color.RED))

Keine Kommentare: