Bug 22949 - swing: JTextField invisible with BoxLayout
Summary: swing: JTextField invisible with BoxLayout
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-21 14:22 UTC by from-classpath
Modified: 2005-07-23 22:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description from-classpath 2005-05-21 14:22:02 UTC
Steps to reproduce:
1. Compile and run the attached testcase

Expected results:
1. A window with two labels and a textfield between the labels shows up.

Actual results:
1. A window with two labels shows up but the textfield is not visible.

Testcase:

import javax.swing.*;
import java.awt.*;
public class jtextfield extends JFrame {
        public static void main(String[] args) {
                (new jtextfield()).show();
        }
        public jtextfield() {
                JPanel panel = new JPanel();
                panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
                panel.add(new JLabel("label1"));
                panel.add(new JTextField(4));
                panel.add(new JLabel("label2"));
                this.setContentPane(panel);
                this.pack();
        }
}

If I comment out the line that does setLayout the textfield is visible.
Comment 1 from-classpath 2005-05-22 14:20:25 UTC
Thank you for reporting. I'll take care of this. I'm quite sure it has something to do with the calculation of the text fields size. When the textfield is for example instantiated with new JTextField("Hello world") then it correctly shows up.
Comment 2 from-classpath 2005-05-22 16:00:15 UTC
I checked in a fix for that. The problem was that getMaximumSize() was not implemented in javax.swing.plaf.basic.BasicTextUI and therefore some useless default was returned, effectivly constraining the textfield's size to 0.

Could you please check if that works for you too?
Comment 3 from-classpath 2005-05-22 18:06:24 UTC
Yes, it works now with current classpath cvs HEAD. Thanks a lot!
Comment 4 from-classpath 2005-05-22 18:09:29 UTC
Ok, in this case I close this bug. Thanks alot for reporting!