简体   繁体   中英

Text on JTextField doesn't appear until frame resize

When I click on a button a property frame appears. Each row has these 3 fields : JLabel name, JTextField value, JSlider slider. My problem is that when the frame shows, it displays the values correctly, but the text in the JTextField fails to appear until I resize the frame for a bit. I use GridLayout for the JPanel containing the components Any suggestions on what I might do?

frame = new JFrame();
    frame.setSize(500, 400);
    frame.setTitle("Properties of " + nume);

    ok = new JButton("OK");
    no = new JButton("Cancel");

    modified = true;

// <"Labels, sliders ,text fields">

// <"add the components on the panel">

    buttonsPanel.add(ok);
    buttonsPanel.add(no);

    JSplitPane framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jsp, buttonsPanel);
    framePanel.setDividerLocation(0.9);
    framePanel.setDividerSize(0);
    framePanel.setResizeWeight(1);

    frame.add(framePanel);

Here is what my frame shows the 1st time: 在此处输入图片说明

And then after I resize it the values appear: 在此处输入图片说明

在JTextField的父控件上调用doLayout()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM