我试图将jButton位置更改为右边,当jPanel出现时,但唯一的变化是jPanel出现并消失。
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
n++;
if((n % 2) == 1){
jPanel1.setVisible(true);
jButton1.setLocation(200, 0);
}
if((n % 2) == 0){
jPanel1.setVisible(false);
jButton1.setLocation(0, 0);
}
}
但如果我只写下面的部分,双击将改变jButton的位置。我想通过一次点击查看更改。
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
jPanel1.setVisible(true);
jButton1.setLocation(200,0);
}