主方法中new MyFrame()import java.awt.*;import javax.swing.*;public class MyFrame extends Frame{MyFrame(){super("test.fuckyou");setLayout(null);setSize(1920, 1080);Button[] button = new Button[3];button[0] = new Button("1");button[1] = new Button("1");button[2] = new Button("1");button[0].setBounds(960, 300, 50, 50);button[1].setBounds(660, 700, 50, 50);button[2].setBounds(1260, 700, 50, 50);add(button[0]);add(button[1]);add(button[2]);setVisible(true);}public void paint(Graphics g){g.drawLine(985, 325, 685, 725);}}這樣可以實現把Frame換為JFrame,Button換為JButtonimport java.awt.*;import javax.swing.*;public class MyFrame extends JFrame{MyFrame(){super("test.fuckyou");setLayout(null);setSize(1920, 1080);JButton[] button = new JButton[3];button[0] = new JButton("1");button[1] = new JButton("1");button[2] = new JButton("1");button[0].setBounds(960, 300, 50, 50);button[1].setBounds(660, 700, 50, 50);button[2].setBounds(1260, 700, 50, 50);add(button[0]);add(button[1]);add(button[2]);setVisible(true);}public void paint(Graphics g){g.drawLine(985, 325, 685, 725);}}下半部分代碼實現的是一條線和一個按鈕,而且移動窗口按鈕也不見了上半部分代碼可以實現3個按鈕和一條線,下面的代碼應該怎么改
添加回答
舉報
0/150
提交
取消