需求:只完成界面布局,暂时不实现功能
效果图:
代码:
import java.awt.Frame;
import java.awt.Panel;
import java.awt.Color;
import java.awt.*;
public class DemoTest {
private Panel firstLine,secondLine,thirdLine;
private Frame mainBody;
/** Creates a new instance of DemoTest */
public static void main(String[] args){
DemoTest d = new DemoTest();
d.toCreateUi();
}
public void createLine(String msg,String msg2, Panel obj){
obj = new Panel();
obj.setSize(1200,300);
obj.setBackground(Color.WHITE);
obj.setLayout(new BorderLayout());
Panel right = new Panel();
right.setSize(800,300);
right.setBackground(Color.WHITE);
right.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
right.add(new Button(msg));
Choice numChooser = new Choice();
numChooser.add("0");
numChooser.add("1");
numChooser.add("2");
numChooser.add("3");
right.add(numChooser);
right.add(new Button("MID"));
right.add(new Button("MNAME"));
right.add(new Button("SNAME"));
right.add(new Button("时长"));
Choice tChooser = new Choice();
tChooser.add("0");
tChooser.add("1");
tChooser.add("2");
tChooser.add("3");
right.add(tChooser);
right.add(new Button("间隔"));
Choice jChooser = new Choice();
jChooser.add("0");
jChooser.add("1");
jChooser.add("2");
jChooser.add("3");
right.add(jChooser);
right.add(new Button("次数"));
Choice mChooser = new Choice();
mChooser.add("0");
mChooser.add("1");
mChooser.add("2");
mChooser.add("3");
right.add(mChooser);
Panel selectBox = new Panel();
selectBox.setLayout(new GridLayout(1,2));
selectBox.add(new Checkbox("编辑",null,true));
selectBox.add(new Checkbox("生效",null,false));
right.add(selectBox);
TextArea ta = new TextArea();
ta.setSize(800,300);
ta.setVisible(true);
Panel bigRight = new Panel();
bigRight.setLayout(new BorderLayout());
bigRight.add("North", right);
bigRight.add("South",ta);
Panel left = new Panel();
left.setSize(350,300);
left.setBackground(Color.WHITE);
left.setLayout(new BorderLayout());
Panel head = new Panel();
head.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
head.add(new TextField(msg2,10));
head.add(new Button("MsgId"));
head.add(new Button("MsgName"));
left.add("North", head);
left.add("South", new TextArea());
obj.add("West",bigRight);
obj.add("East",left);
mainBody.add(obj);
}
public void toCreateUi(){
mainBody = new Frame("Test");
mainBody.setBackground(Color.lightGray);
mainBody.setSize(1200,600);
mainBody.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
//第一行控制
firstLine = new Panel();
firstLine.setSize(1200,100);
firstLine.setBackground(Color.WHITE);
firstLine.setLayout(new FlowLayout(FlowLayout.LEFT,20,5));
firstLine.add(new Button("车型"));
Choice carChooser = new Choice();
carChooser.add("X1");
carChooser.add("X3");
carChooser.add("X4");
carChooser.add("X5");
firstLine.add(carChooser);
firstLine.add(new TextField("列表:"));
firstLine.add(new TextField("展示选中文件的路径",80));
firstLine.add(new Button("选中文件"));
firstLine.add(new Button("开始"));
mainBody.add(firstLine);
//第二行控制
createLine("通道A","block_A",secondLine);
//第三行控制
createLine("通道B","block_B",thirdLine);
mainBody.setVisible(true);
}
}