我在使用我的Mac上的GridbagLayout设置JTextArea的高度时遇到了麻烦。在Mac上,它只显示为一行,当我在PC上运行程序时,高度是正确的。我一直在努力寻找很多,但我还没有遇到任何解决方案,你们认为可能是什么问题?mac上的gridbaglayout中JTextArea的高度
编辑:我只注意到这个问题可能在我的代码别的地方位于..当我调整我的窗口尺寸越大变得正确,但它仍然是一个单行和正确的大小之间切换
这基本上是我的代码:
JPanel jp = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(1, 1, 1, 1);
final JTextArea tArea = new JTextArea("Text", 10, 10);
final JScrollPane tAreaPane = new JScrollPane(tArea);
tArea.setLineWrap(true);
tArea.setRows(15);
c.gridx = 0;
c.gridy = 2;
c.gridwidth = 4;
center.add(tAreaPane, c);
伊夫尝试设置:
tArea.setSize(200,400);
tArea.setPreferredSize(new Dimension(200, 400));
tArea.setBounds(5, 5, 100, 100);
在tArea和tAreaPane上。我在哪里做错了?
问候,
丹尼尔
为了更好地帮助越早,张贴[SSCCE(HTTP造成的: //sscce.org/)。 – 2012-02-15 09:47:43
我刚刚注意到问题可能位于我的代码中的其他地方..当我调整我的窗口的大小时,尺寸变得正确..但是它仍然在单线和正确尺寸之间切换 – Daniel 2012-02-15 09:57:00
我看到这种突然变化, GridBagLayout'在Mac OS X上,但我从来没有追赶过它。 – trashgod 2012-02-15 13:56:30