• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JScrollPane collapses after minimizing GUI

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JTextArea component which i want to use to capture some text and
a JScrollPane for the scrollable view. what happens is that when the program
runs initially, everything is arranged as i expect it to be (using the GridBag Layout), but after i type text in the TextArea and lets say i happen to minimize the GUI and maximize it again, the ScrollPane collapses vertically to almost half the original size and distorts the GUI. The code that creates the TextArea and the scrollpane is as follows.


txtMessage.setColumns(30);
txtMessage.setRows(5);
txtMessage.setFont(new Font("Arial", 0, 12));
txtMessage.setLineWrap(true);
txtMessage.setBorder(new javax.swing.border.BevelBorder (javax.swing.border.BevelBorder.LOWERED));
txtMessage.getDocument().addDocumentListener(new MyDocumentListener());
JScrollPane displayScrollPane = new JScrollPane(txtMessage);
displayScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
c.gridx = 1;
c.gridy = 1;
c.weightx = 1.0;
c.weighty = 1.0;
c.gridwidth = 6;
c.ipadx = 0;
c.ipady = 40;
c.insets = new Insets(3, 3, 3, 3);
single.add(displayScrollPane, c);


any ideas on how to stop the scrollpane from collapsing.

thanks
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I seem to remember there's a JTextArea method, possibly inherited, that says to get the sizing from the container. I could be misremembering.

There could also be some other component in the grid bag that is affecting the sizing of the grid bag's columns and rows.
 
reply
    Bookmark Topic Watch Topic
  • New Topic