【问题标题】:JPanel consists from textFieldsJPanel 由 textFields 组成
【发布时间】:2016-11-03 14:15:52
【问题描述】:

如何防止缩小只包含 JFormattedTextFields 的 JPanel。

JFormattedTextField textF1;
JFormattedTextField textF2;

       textF1 = new JFormattedTextField(numberFormat);
       textF2     = new JFormattedTextField(numberFormat);

JPanel labelPane = new JPanel(new GridLayout(0,1));
        labelPane.add(textF1)
        labelPane.add(textF2)



        setBorder(BorderFactory.createEmptyBorder(50, 50, 50, 50));

        add(labelPane, BorderLayout.LINE_START);
        add(fieldPane, BorderLayout.CENTER);
        add(imagePane, BorderLayout.LINE_END);

问题在于 fieldPane。它总是缩小。我试图将文本字段设置为最小尺寸,手动设置尺寸。甚至设置 prefferd 大小,setMaximumSize。不是这个作品。LabelPane 和 imagePane 工作正常。

【问题讨论】:

标签: java swing jpanel textfield


【解决方案1】:

方法setColumns(int) 有效。谢谢。

【讨论】:

  • 有时最简单的方法(通过仔细检查 Java 文档发现,包括inherited methods)是最好的方法。 ;)
猜你喜欢
  • 1970-01-01
  • 2015-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多