So if i have a JMenu
& JMenuBar
defined such that:
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu1.setText("About");
jMenuBar1.add(jMenu1);
// Finally
setJMenuBar(jMenuBar1);
and with this the Menu "About" is aligned to the left most side of the menu bar. Is there anyway that i can align this menu on the right most side of the menu bar?
There is a patch available for this:
jMenuBar.add(Box.createHorizontalGlue());
Add this line before adding menu to menubar and your menu will come on right side of menubar. Something like:
.....
jMenu1.setText("About");
jMenuBar1.add(Box.createHorizontalGlue()); <-- horizontal glue
jMenuBar1.add(jMenu1);
.....
jMenuBar1.add(Box.createHorizontalGlue());
and don't forget alignt JMenu
with JMenuItem
too
JMenu.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With