0

我正在尝试创建一个文本编辑器,所以我创建了一个扩展为 JScrollPane 的 JTextArea。

我正在运行 Windows 10 和 java 版本“1.6.0_38”

我对 javax.swing 相当陌生(到目前为止我只学过 AWT),当我尝试回到旧的 java.awt.TextArea 时,触控板似乎可以工作。

public class CustomFrame extends JFrame {
    public CustomFrame() {
        this.setBackground(new Color(255, 255, 255));   
        this.setEditor();
        this.pack();
    }
    private void setEditor() {
        this.setTitle("Text Editor");
        JTextArea text = new JTextArea("");
        JScrollPane sp = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        this.getContentPane().add(sp);
        this.setVisible(true);
    }
}

在 javax.swing.JScrollPane 中,应用程序未检测到触控板,而是在后台滚动命令行窗口。

4

0 回答 0