0
由於某種原因,當窗口最小化並且被恢復時,jscrollpane以某種方式混淆了佈局。JScrollpane在最小化後丟失大小
請注意,如果文本區域中的文本長度不超過文本區域的大小(即不顯示垂直滾動條),則不會發生這種情況。
任何人都可以看到它有什麼問題嗎?
我下面的代碼:
super (new GridBagLayout());
textField = new JTextArea(20,80);
textField.addKeyListener(null);
JScrollPane scrollPane1 = new JScrollPane(textField);
textArea = new JTextArea(20, 80);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
String[] dropValues = {"Format code","Add commas","Add quotes"};
dropdown = new JComboBox(dropValues);
dropdown.setSelectedIndex(0);
myButton = new JButton("Do it babe!!!");
myButton.addActionListener(this);
//Add Components to this panel.
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
// c.fill = GridBagConstraints.HORIZONTAL;
add(dropdown, c);
c.anchor = GridBagConstraints.CENTER;
// c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
add(scrollPane1, c);
add(myButton, c);
add(scrollPane, c);
當第一次啓動應用程序
當比textarea的高度文本不再
恢復
請將此代碼剪掉已經說明過的問題?,爲了更好地幫助您儘快發佈SSCCE,簡短,可運行,可編譯 – mKorbel