Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!