import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
//定义设置的图形界面
public class t31 extends JFrame {
JComboBox[] jcb=new JComboBox[6];
JCheckBox check;
JButton[] jb=new JButton[2];
Font font=new Font("宋体",Font.PLAIN,14);
public t31(){//(Action[] actions){
for(int i=0;i<6;i++){
jcb[i]=new JComboBox();
}
check=new JCheckBox("默认值");
for(int i=0;i<2;i++){
jb[i]=new JButton();
jb[i].setRequestFocusEnabled(false);
}
Container container=getContentPane();
container.setLayout(new BorderLayout(2,2));
JPanel jpc=new JPanel();
jpc.setLayout(new GridLayout(6,1,2,2));
for(int i=0;i<6;i++){
jpc.add(jcb[i]);
}
JPanel jpw=new JPanel();
jpw.setLayout(new GridLayout(6,1,2,2));
for(int i=0;i<6;i++){
jpw.add(new JLabel(" 命令按钮"+(6-i)),SwingConstants.CENTER);
}
JPanel jps=new JPanel();
jps.setLayout(new GridLayout(2,1,2,2));
JPanel jpsn=new JPanel();
jpsn.add(check);
JPanel jpss=new JPanel();
jpss.setLayout(new GridLayout(1,2,2,2));
for(int i=0;i<2;i++){
jpss.add(jb[i]);
}
jps.add(jpsn);
jps.add(jpss);
container.add(new JLabel("请输入命令按钮对应的命令操作",SwingConstants.CENTER),BorderLayout.NORTH);
container.add(jpw,BorderLayout.WEST);
container.add(jpc,BorderLayout.CENTER);
container.add(jps,BorderLayout.SOUTH);
setTitle("按钮设置");//设置窗体名称
setLocation(600, 250);//设置窗体左上角位置,默认为(0, 0)在屏幕左上角
setSize(200,300);//设置窗体(包括边框)像素大小,全屏为(1366,740),因为要显示底部任务栏,默认为只有边框无窗体
setVisible(true);//设置窗体可见,默认为false不可见
setResizable(false);//设置窗体可变性,默认为true窗体大小可变
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//关闭窗口时退出程序
}
public static void main(String[] args){
new t31();
}
}
|
|