importjava.awt.*;importjavax.swing.*;publicclassGUIDemo{publicstaticvoidmain(String[]args){Framef=newFrame("候选人输入");Panelp1=newPanel();Panelp2=newPanel();Panelp3=new...
import java.awt.*;
import javax.swing.*;
public class GUIDemo {
public static void main(String[] args) {
Frame f=new Frame("候选人输入");
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Label l1=new Label("第一候选人");
Label l2=new Label("第一候选人");
Label l3=new Label("第一候选人");
TextField t1=new TextField(30);
TextField t2=new TextField(30);
TextField t3=new TextField(30);
Button b1=new Button("输入");
Button b2=new Button("输入");
Button b3=new Button("输入");
f.setLayout(new GridLayout(4,1));
p1.setLayout(new FlowLayout());
p2.setLayout(new FlowLayout());
p3.setLayout(new FlowLayout());
p1.add(l1);
p1.add(t1);
p1.add(b1);
p1.setBackground(Color.yellow);
p2.add(l2);
p2.add(t2);
p2.add(b2);
p2.setBackground(Color.red);
p3.add(l3);
p3.add(t3);
p3.add(b3);
p3.setBackground(Color.green);
f.add(p1);
f.add(p2);
f.add(p3);
f.setSize(600,300);
f.setVisible(true);
谢谢各位
展开