在我的源代码中,
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Object6 extends JFrame {
JButton p = new JButton("Y");
JButton n = new JButton("N");
public Object6(){
setSize(1280,800);
setVisible(true);
setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g){
p.setLocation(590,500);
n.setLocation(590,550);
add(p);
add(n);
p.setSize(100,50);
n.setSize(100,50);
g.drawString("Does statement 6 apply?", 100, 100);
}
public static void main(String[]args){
new Object6();
}
}
按钮“p”和字符串出现;但是,只有当我单击它应该在的空间时,才会出现按钮“n”。当我删除g.drawString("Does statement 6 apply?", 100, 100);
时,两个按钮同时出现。
g.drawString("Does statement 6 apply?", 100, 100);
当两个按钮同时出现时如何添加?