package six; import java.awt.*; import javax.swing.*; public class FirstSwingApplication extends JFrame{ private JTextField text1,text2,text3; private JTextField text_sum; private JButton btnresult,btnshow; public FirstSwingApplication(){ s(); d(); setSize(300,200); setTitle("first "); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); } private void s(){ text1=new JTextField(10); text2=new JTextField(10); text1=new JTextField(10); text_sum=new JTextField(10); btnresult=new JButton("计算"); btnshow=new JButton("清楚"); } private void d(){ Container a=getContentPane(); setLayout(new GridLayout(4,1)); JPanel pane1=new JPanel(); pane1.add(text1); JPanel pane2=new JPanel(); pane2.add(text2); JPanel pane3=new JPanel(); pane3.add(text_sum); JPanel pane4=new JPanel(); pane4.add(btnresult); JPanel pane5=new JPanel(); pane5.add(btnshow); a.add(pane1); a.add(pane2); a.add(pane3); a.add(pane4); a.add(pane5); } public static void main(String[] args){ JFrame.setDefaultLookAndFeelDecorated(true); FirstSwingApplication frame=new FirstSwingApplication(); frame.setVisible(true); } }
亚努人
田心枫
相关分类