这是我的JPanel.第一个按钮始终可见,但仅当您在其上放置一个光标时,才能看到该条纹.问题出在哪里?
PS如果可以,请使用简单的英语,因为我不会说英语
public class GamePanel extends JPanel implements KeyListener{
GamePanel(){
setLayout(null);
}
public void paint(Graphics g){
JButton buttonShip1 = new JButton();
buttonShip1.setLocation(10, 45);
buttonShip1.setSize(40, 40);
buttonShip1.setVisible(true);
add(buttonShip1);
JButton buttonShip2 = new JButton();
buttonShip2.setLocation(110, 145);
buttonShip2.setSize(440, 440);
buttonShip2.setVisible(true);
add(buttonShip2);
}
}
Run Code Online (Sandbox Code Playgroud)