The moose likes Swing / AWT / SWT and the fly likes Setting a Default width for JOptionPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting a Default width for JOptionPane" Watch "Setting a Default width for JOptionPane" New topic

Setting a Default width for JOptionPane

Andrew Geroge Alexander
Ranch Hand

Joined: Feb 14, 2012
Posts: 31
I have a JTable of notes, but I do not want to show the entire notes on table level, when the user clicks the table a JOptionPane is opened to display the messages.. However, if the notes inside is long, then the message box also is long.. I have attached a jpeg to explain what I am saying, can I set a default width. so if the message is really big, it will be wrapped to accommodate? I am using Jave NetBeans IDE 7.1

[Thumbnail for LongBar.jpg]

Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

You can:
  • Split the message you're displaying to multiple lines
  • Create a panel and set its size, then pass it as parameter when displaying JOptionPane dialog

  • The quieter you are, the more you are able to hear.
    m Korbel
    Ranch Hand

    Joined: Jun 19, 2012
    Posts: 174
    - put JTextArea(String text, int rows, int columns) (disabled) in JScrollPane

    JOptionPane.showConfirmDialog(null, myJScrollPane, "Quesion", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);

    - use Html with JLabel / (disabled) JTextPane / EditorPane
    I agree. Here's the link:
    subject: Setting a Default width for JOptionPane
    It's not a secret anymore!