返回列表 發帖
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;

  3. import javax.swing.JButton;
  4. import javax.swing.JFrame;
  5. import javax.swing.JLabel;
  6. import javax.swing.JTextField;

  7. public class asdfgh implements ActionListener
  8. {
  9.         public static void main(String[] args)
  10.         {
  11.                 asdfgh app = new asdfgh();
  12.         }

  13.         public void actionPerformed(ActionEvent e)
  14.         {

  15.         }

  16.         private JFrame fm;
  17.         private JTextField tf1, tf2;
  18.         private JButton btn1;
  19.         private JLabel lb1, lb2;

  20.         asdfgh() {
  21.                 fm = new JFrame("My First Swing Example");
  22.                 tf1 = new JTextField();
  23.                 tf2 = new JTextField();
  24.                 lb1 = new JLabel("User");
  25.                 lb2 = new JLabel("Password");
  26.                 btn1 = new JButton("login");

  27.                 tf1.setBounds(100, 24, 225, 25);
  28.                 tf1.addActionListener(this);
  29.                 tf2.setBounds(100, 68, 225, 25);
  30.                 tf2.addActionListener(this);

  31.                 lb1.setBounds(10, 20, 60, 30);
  32.                 lb2.setBounds(10, 60, 60, 40);

  33.                 btn1.setBounds(10, 135, 92, 25);
  34.                 btn1.addActionListener(this);

  35.                 fm.setBounds(100, 100, 360, 210);
  36.                 fm.setVisible(true);
  37.                 fm.setResizable(true);
  38.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  39.                 fm.setLayout(null);
  40.                 fm.add(tf1);
  41.                 fm.add(tf2);
  42.                 fm.add(lb1);
  43.                 fm.add(lb2);
  44.                 fm.add(btn1);
  45.         }
  46. }
複製代碼
我是眾神之王XXX  I love you
0000000000

TOP

返回列表