标签:java
2. import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Menu; import java.awt.MenuBar; import java.awt.MenuItem; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextArea; public class Test { public static void main (String[] args){ JFrame test= new JFrame(); test.setLayout(new GridLayout(2,1)); final Menu menu1 = new Menu("文件"); final Menu menu2 = new Menu("编辑"); final Menu menu3 = new Menu("帮助"); MenuBar menubar = new MenuBar(); menubar.add(menu1); menubar.add(menu2); menubar.add(menu3); test.setMenuBar(menubar); JPanel pan1 = new JPanel(new FlowLayout()); String font[] = {"宋体","啊杜体","向阳体","帅帅体","鹏程体"}; String fontSize[] = {"12","24","36","48", "72"}; final JComboBox cb1 = new JComboBox(font); final JComboBox cb2 = new JComboBox(fontSize); JCheckBox kb1 = new JCheckBox("粗体"); JCheckBox kb2 = new JCheckBox("斜体"); JRadioButton rb1 = new JRadioButton("红", true); JRadioButton rb2 = new JRadioButton("绿"); JRadioButton rb3 = new JRadioButton("蓝"); pan1.add(cb1); pan1.add(cb2); pan1.add(kb1); pan1.add(kb2); pan1.add(rb1); pan1.add(rb2); pan1.add(rb3); test.add(pan1); JTextArea text1 = new JTextArea("Welcome 欢迎",35,25); test.add(text1); test.setVisible(true); test.pack(); } }
标签:java
原文地址:http://anglecode.blog.51cto.com/5628271/1619876