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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Setting a Default width for JOptionPane  RSS feed

 
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
[Thumbnail for LongBar.jpg]
Long message
 
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

  •  
    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
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!