gpt4 book ai didi

java - 为什么水平滚动条不适用于我的 JTextArea?

转载 作者:行者123 更新时间:2023-12-02 05:40:58 32 4
gpt4 key购买 nike

尝试读取和写入文本文档,一切正常,但水平滚动条不可见。

我尝试手动激活 JScrollPane 水平滚动条,但没有成功。

公共(public)类 JScrollPaneÜbung 扩展了 JFrame{

private static final long serialVersionUID = 1L;
private JTextArea area;
private JTextField field;
private JScrollPane scroll;
private JButton dateisuche;
private JButton dateispeichern;
private Panel panel;
private Panel sPanel;


public JScrollPaneÜbung()
{
area = new JTextArea(32, 41);
field = new JTextField(30);
scroll = new JScrollPane(area);
dateispeichern = new JButton("Speichern");
dateisuche = new JButton("Durchsuchen");
panel = new Panel();
sPanel = new Panel();
createGUI();
}

public void createGUI() {
setBounds(200, 200, 600, 600);
BorderLayout b = new BorderLayout();
setLayout(b);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
dateisuche.addActionListener(new JScrollPaneListener(this));
dateispeichern.addActionListener(new JScrollPaneListener(this));
panel.add(dateisuche);
panel.add(field);
panel.add(scroll);
sPanel.add(dateispeichern);

add(panel, BorderLayout.NORTH);
add(sPanel, BorderLayout.SOUTH);

setVisible(true);

}
public static void main(String[] args) {
new JScrollPaneÜbung();
}

没有可见的水平滚动条,但我的文本文档比 JTextArea 长

最佳答案

您使用的是常规 JPane。请改用 JScrollPane。您可以在此处找到可以指导您的文档。 Resource

关于java - 为什么水平滚动条不适用于我的 JTextArea?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56139022/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com