使用下面定义的 JPanel(嵌入在 JSplitPane 中的 JTabPanel 中):
如果我最大化,面板将正确重绘为新尺寸面板未重绘为预期尺寸
container.setLayout(new MigLayout("debug,fillx,wrap 5",
"[75:75:75][fill][75:75:75][fill][140:140:140,align left]"));
container.add(labelSrcTitle, "span 4");
container.add(buttonAddRef, "");
container.add(srcTitle, "span");
container.add(srcListing, "span,grow");
container.add(sepRef,"span,growx");
container.add(refTitle,"span");
container.add(refListing,"span 4,grow");
container.add(buttonEdit,"split 2");
container.add(buttonDelete,"");
container.add(name,"span 4,growx");
container.add(buttonSEdit,"split 3");
container.add(buttonSDelete);
container.add(buttonSAdd,"");
container.add(lType,"");
container.add(lClaim,"grow");
container.add(lQual,"");
container.add(lNotes,"grow");
container.add(buttonCEdit, "split 3");
container.add(buttonCDelete);
container.add(buttonCAdd, "");
我希望(并期望)如果我最大化然后最小化,屏幕将重新绘制为其原始配置。我错过了什么?如果重要的话,所有 JTextArea 字段都是换行的。
编辑:
这是一个更简单的示例 - 问题似乎与设置了换行的 JTextArea 有关。JFrame 中的以下代码重新创建了该问题:
JPanel root = new JPanel(new MigLayout("fill,debug"));
JTextArea t = new JTextArea();
t.setLineWrap(true);
root.add(t,"growx");
setContentPane(root);
setLocationRelativeTo(null);
setSize(200, 200);