Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting a Default width for JOptionPane

 
Andrew Geroge Alexander
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
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
LongBar.jpg
Long message
[Thumbnail for LongBar.jpg]
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  •  
    m Korbel
    Ranch Hand
    Posts: 174
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    - 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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic