1 package 界面; 2 import java.awt.*; 3 4 import javax.swing.JFrame; 5 import javax.swing.*; 6 //import javax.swing.table.*; 7 8 9 public class DMGL_Interface extends JFrame{ 10 11 12 //定义 按钮和标签 13 JLabel L_Header,L_Language,L_Type,L_Title; 14 JComboBox Language,Type; 15 JTextField Title; 16 JTextArea Code; 17 JButton Confirm,Cancle; 18 19 20 public DMGL_Interface () 21 { 22 23 24 25 //布局 26 Container contentPane = getContentPane();//定义容器类对象 27 setLayout(new FlowLayout());//不设置布局 28 setTitle("添加代码"); 29 //语言框 30 JPanel P_Header=new JPanel(); 31 String [] SLanguage=new String[]{"默认","java","javaScript","c", 32 "c++","c#","PHP","Delphi","SAS","PL/SQ","web","ABAP"}; 33 L_Header =new JLabel("语言"); 34 Language=new JComboBox(SLanguage); 35 36 37 P_Header.add(L_Header); 38 P_Header.add(Language); 39 40 //类型框 41 L_Type =new JLabel("类型"); 42 String [] SType=new String[]{"默认","函数","知识","模块","程序",}; 43 Type=new JComboBox(SType); 44 45 P_Header.add(L_Type); 46 P_Header.add(Type); 47 add(P_Header); 48 //标题框 49 JPanel P_Title=new JPanel(); 50 L_Title =new JLabel("请输入标题"); 51 Title =new JTextField("",20); 52 P_Title.add(L_Title); 53 P_Title.add(Title); 54 add(P_Title); 55 //文本域 56 Code = new JTextArea("",20,32); 57 JScrollPane G_Code = new JScrollPane(Code,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 58 add(G_Code); 59 60 61 //按钮 62 JPanel P_Button=new JPanel(); 63 Confirm=new JButton("保存"); 64 Cancle=new JButton("取消"); 65 P_Button.add(Confirm); 66 P_Button.add(Cancle); 67 add(P_Button); 68 //设置窗口可见话和大小 69 setSize(400,550); 70 setVisible(true); 71 } 72 73 74 75 76 77 78 //主函数 79 public static void main(String args[]) 80 { 81 new DMGL_Interface(); 82 } 83 84 }
时间: 2024-10-24 04:18:05