posted 19 years ago
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