This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to right justify buttons in JOptionPane  RSS feed

 
Jess Ryan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,

Is it possible to right justify the components that you pass as options to a JOptionPane, and if so, how? I love the convenience of the JOptionPane.showOptionDialog(...), but I need to have the buttons right aligned instead of centered.

Thanks!
-Jess
 
Brian Cole
Author
Ranch Hand
Posts: 947
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jess Finley:
Is it possible to right justify the components that you pass as options to a JOptionPane, and if so, how? I love the convenience of the JOptionPane.showOptionDialog(...), but I need to have the buttons right aligned instead of centered.


Are you talking about components you pass in as the "message", as "selectionValues", or as "options"? For "message" you can pass in a JPanel with the components aligned as you see fit. For the others it's pretty much up to the UI.

You can try setting the OptionPane.buttonOrientation system property to SwingConstants.RIGHT. See here.
 
Jess Ryan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean the components I pass as "options". I'm not quite familiar with the synth stuff. Guess I'll just stick to making my own.

Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!