我在JFrame中有一个JTextField和一个JTextArea.但是,当应用程序运行时,如果我最小化窗口,则会调整JTextField的大小.它的高度通常是双倍或三倍,但每次调整大小的方式并不一致.我不知道为什么会发生这种情况.我并不是真的要求直接解决方案,只是可能导致问题的一些可能的事情.如果你能帮助我,那就太好了.谢谢
编辑:这是我用来初始化它的代码:
public class Console extends JPanel implements ActionListener, Serializable {
boolean ready = false;
protected JTextField textField;
protected JTextArea textArea;
private final static String newline = "\n";
Game m_game;
Thread t;
public Console(Game game) {
super(new GridBagLayout());
m_game = game;
textField = new JTextField(20);
textField.setPreferredSize(null);
textField.addActionListener(this);
textArea = new JTextArea(20, 60);
textArea.setEditable(false);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
Font comic = new Font("Serif", Font.PLAIN, 14);
textArea.setFont(comic);
JScrollPane scrollPane = new JScrollPane(textArea);
//Add Components to this panel.
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = …Run Code Online (Sandbox Code Playgroud)