【发布时间】:2018-10-09 11:42:06
【问题描述】:
我正在使用 Java 中的 SWing 编写程序,但这是我的问题,当我按下按钮时,我希望每次按下按钮时,我都会在与前一个相同的位置更新一个新图像,我尝试在代码的动作侦听器中执行此操作,但图像未更新,并且是一开始的那个,有人可以帮我吗?非常感谢。
public MainWindow() {
initComponents();
setIconImage(Icono);
this.setLocationRelativeTo(null);
this.setResizable(false);
Imagen fondo=new Imagen();
this.add(fondo, BorderLayout.CENTER);
this.pack();
PracticeMode = new javax.swing.JDialog();
}
private void StartPracticeActionPerformed(java.awt.event.ActionEvent evt) {
ButtonsSelected(1);
StartGame Practice=new StartGame(OpcComboBox, numUnity, numTrys,
opcNotas, false);
PracticeBF.dispose();
PracticeMode.setIconImage(Icono);
PracticeMode.setBounds(460, 600, 460, 538);
PracticeMode.setVisible(true);
CirculodeQuintasBW BW=new CirculodeQuintasBW();
PracticeMode.add(BW, BorderLayout.CENTER);
PracticeMode.pack();
PracticeMode.setLocationRelativeTo(null);
PracticeMode.setResizable(false);
}
这是我要刷新的图像,在此之前它应该是另一个图像,但是每次我尝试刷新它都不起作用... PracticeMode 应该是一个 JDialog,有人可以帮帮我吗?
private void D2ActionPerformed(java.awt.event.ActionEvent evt) {
CirculodeQuintasD D=new CirculodeQuintasD();
PracticeMode.add(D, BorderLayout.CENTER);
PracticeMode.validate();
PracticeMode.repaint();
PracticeMode.pack();
}
【问题讨论】:
标签: java swing jframe refresh jdialog