尝试读写文本文档,一切正常,但是水平滚动条不可见。
我尝试手动激活JScrollPane水平滚动条,但这不是结果。
公共类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长