Java 如何使JTextField中的光标跨越FlowLayout中的多行?

Java 如何使JTextField中的光标跨越FlowLayout中的多行?,java,swing,jtextfield,flowlayout,Java,Swing,Jtextfield,Flowlayout,如何使光标从JTextField的左上角开始?使用.setPreferredSize()调整高度时,文本保持居中。下面是字段和按钮的代码 public class GUIWindow extends JFrame{ private JTextField inputBox = new JTextField(20); private JTextField outputBox = new JTextField(20); private JButton encodeButton

如何使光标从JTextField的左上角开始?使用.setPreferredSize()调整高度时,文本保持居中。下面是字段和按钮的代码

public class GUIWindow extends JFrame{

    private JTextField inputBox = new JTextField(20);
    private JTextField outputBox = new JTextField(20);
    private JButton encodeButton = new JButton("Encode");
    private JButton decodeButton = new JButton("Decode");

    public GUIWindow(){
        JPanel mainPanel = new JPanel(new FlowLayout());
        outputBox.setPreferredSize(new Dimension(80, 80));
        inputBox.setPreferredSize(new Dimension(80, 80));
        outputBox.setEditable(false);
        mainPanel.add(inputBox);
        mainPanel.add(encodeButton);
        mainPanel.add(decodeButton);
        mainPanel.add(outputBox);
        Container container = getContentPane();
        container.add(mainPanel);
    }
}

如果您正在寻找一个多行控件,那么您应该使用一个而不是JTextField。

正是我所缺少的。谢谢