• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to increase the size of JOptionPane

 
Sri Palem
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me how to increase the size of JOptionPane? setSize() and setPrefferedSize() is not working for me...
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried setting the preferred size of a JPanel and then add that JPanel as the JOptionPane's Object?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the source code for JOptionPane, you will notice that a pack() is called on the dialog. This is for a very good reason. Dialogs should be used to to convey minimal but important information to the users. Considering this, the dialog size is kept at a minimum and that is the reason why you were not able to resize.

If you find yourself in a situation, where you require to explicitly resize the dialog size, then it would be a good idea to review your UI design and user experience. If you still insist on going by this route, the Pete has already given you the solution.
 
Sri Palem
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Pete for your response. I am able to widen my JOptionPane according to my client requirement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!