-1
textArea = new JTextArea(textString);
JScrollPane text = new JScrollPane(textArea,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
text.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
而且我將JScrollPane文本添加到JTabbedPane中,沒什麼特別的。JTabbedPane中的JTextfield過大
但是,當我切換選項卡時,texfield擴展並調整整個窗口的大小。
JFrame frame = new JFrame();
frame.setSize(600, 500);
JPanel main = new JPanel();
main.setLayout(new BorderLayout(0,0));
main.setBorder(new EmptyBorder(10, 10, 10, 10));
textArea = new JTextArea(textString);
JScrollPane text = new JScrollPane(textArea,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
text.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
JTabbedPane tabs = new JTabbedPane();
tabs.add("Text lines", text);
tabs.add("Another", new JPanel());
main.add(new JLabel("test"), BorderLayout.NORTH);
main.add(tabs, BorderLayout.SOUTH);
frame.setContentPane(main);
frame.pack();
和你的問題是...... – 2013-02-20 14:17:03
我不希望窗口拉伸,當我明顯地取消選擇選項卡。 – RobotRock 2013-02-20 14:21:26
究竟是什麼問題?你如何將JTabbedPane添加到層次結構中?發佈[SSCCE](http://sscce.org)並解釋您期望的內容 – 2013-02-20 14:21:49