我仍然是 Swing 課程的菜鳥,我想在用戶激活按鈕后清除螢屏。
JButton tes=new JButton("TEST");
tes.setBounds(550, 375, 200, 75);
tes.setFocusable(false);
tes.setFont(new Font("comic sans",Font.PLAIN,20));
tes.setBackground(Color.white);
tes.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2, true));
tes.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
try {
test('T');
}
catch(IOException e1) {
throw new UncheckedIOException(e1);
}
}
});
f.add(tit);f.add(sub);
f.add(pr);f.add(tes);
f.setVisible(true);
}
我使用了以下內容,但實際上并沒有做任何事情。
removeAll()
revalidate();
repaint();
uj5u.com熱心網友回復:
private JFrame frame = new JFrame();
frame.getContentPane().removeAll();
frame.repaint();
你應該這樣使用它
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/388300.html
上一篇:getscaleinstance和scale之間的區別?(擺動爪哇)
下一篇:Python超出遞回限制
