palyxk
palyxk

Reputation: 351

JPanel consists from textFields

How to prevent shrinking JPanel which contains only JFormattedTextFields.

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);

problem is with fieldPane. It always shrinks. I have tried to set textfield to minimum size, set manually dimensions. Even set prefferd size, setMaximumSize. Not of this works.LabelPane and imagePane work fine.

Upvotes: 0

Views: 31

Answers (1)

palyxk
palyxk

Reputation: 351

Method setColumns(int) worked. Thanks.

Upvotes: 2

Related Questions