• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to right justify buttons in JOptionPane  RSS feed

 
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
 
Author
Ranch Hand
Posts: 964
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!
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!