I am placing [OK] and [Cancel] buttons horizontally in a Box (which has BoxLayout). Later I add this Box to BorderLayout.PAGE_END in content pane of JDialog. This works perfect in Windows, so [OK] is to left of [Cancel] - just like I have added.
When I test in Linux, the placement of buttons is same as Windows - [OK] to left of [Cancel]. This, again, follows from code.
However, in Linux (Ubuntu), the default placement for buttons is [Cancel] to left of [OK]. This contrasts with my code and placement of buttons.
So, my question is : Whether Java has some kind of constant - say OS_PLACEMENT, which can be set somewhere which will make [Cancel] button appear to left of [OK] in Linux? I am asking this because I know Java supports constants for RTL and LTR layout. Thus, I thought, there might be some constant(s) related to this kind of placement.
I wish to mention that I do set L&F of my Swing app to System L&F. Following is my first line in main()
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
No, Java will not do this automatically for you.
Consider using the free "JGoodies Form" library. It has a class called "ButtonBarBuilder" which will lay out buttons in the correct order according to the user's OS.
Otherwise you must manually inspect the value of System.getProperty("os.name") and lay out the buttons according to the value.