• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!