package com.main;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class MassageDialogDeom {
Frame jFrame=new Frame("test control");
TextArea ta=new TextArea(5,10);
Choice color=new Choice();
CheckboxGroup checkboxGroup=new CheckboxGroup();
Checkbox checkbox=new Checkbox("man",checkboxGroup,true);
Checkbox checkbox2=new Checkbox("woman",checkboxGroup,false);
Checkbox isMarried=new Checkbox("is married?");
TextField textField=new TextField(20);
Button button=new Button("ok");
List colorlist=new List(6,true);
public void init(){
Box box=Box.createHorizontalBox();
box.add(textField);
box.add(button);
jFrame.add(box,BorderLayout.SOUTH);
color.add("red1");
color.add("red2");
color.add("red3");
color.add("red4");
// checkbox.setCheckboxGroup(checkboxGroup);
// checkbox2.setCheckboxGroup(checkboxGroup);
Box box2=Box.createHorizontalBox();
box2.add(color);
box2.add(checkbox2);
box2.add(checkbox);
box2.add(isMarried);
Box box3=Box.createVerticalBox();
box3.add(ta);
box3.add(box2);
//组装左边列表框
colorlist.add("红色0");
colorlist.add("红色1");
colorlist.add("红色2");
colorlist.add("红色3");
colorlist.add("红色0");
colorlist.add("红色1");
colorlist.add("红色2");
colorlist.add("红色3");
Box horizontalBox = Box.createHorizontalBox();
horizontalBox.add(box3);
horizontalBox.add(colorlist);
jFrame.add(horizontalBox);
jFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
super.windowClosing(e);
}
});
jFrame.pack();
jFrame.setVisible(true);
}
public static void main(String[] args) {
new MassageDialogDeom().init();
}
}
网友评论