2019-08-31 Modify extends JFrame

package com.foreknow.view;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import com.foreknow.service.UserService;
import com.foreknow.service.impl.UserServiceImpl;

public class Modify extends JFrame {

    private JPanel contentPane;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    private JButton btnNewButton;
    private JButton btnNewButton_1;
    private boolean isModify = false;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Modify frame = new Modify();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public Modify() {
        setTitle("\u4FEE\u6539\u4FE1\u606F");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);

        JLabel lblNewLabel = new JLabel("用户名:");
        lblNewLabel.setBounds(58, 39, 54, 15);
        contentPane.add(lblNewLabel);

        JLabel lblNewLabel_1 = new JLabel("密码:");
        lblNewLabel_1.setBounds(58, 98, 54, 15);
        contentPane.add(lblNewLabel_1);

        JLabel lblNewLabel_2 = new JLabel("email:");
        lblNewLabel_2.setBounds(58, 163, 54, 15);
        contentPane.add(lblNewLabel_2);

        textField = new JTextField();
        textField.setBounds(199, 36, 140, 21);
        contentPane.add(textField);
        textField.setColumns(10);

        textField_1 = new JTextField();
        textField_1.setBounds(199, 95, 140, 21);
        contentPane.add(textField_1);
        textField_1.setColumns(10);

        textField_2 = new JTextField();
        textField_2.setBounds(199, 160, 140, 21);
        contentPane.add(textField_2);
        textField_2.setColumns(10);

        btnNewButton = new JButton("修改");
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                // 调用业务层的方法
                UserService service = new UserServiceImpl();
                isModify  = service.change(textField.getText(),textField_1.getText(),textField_2.getText(),MainWindow.id);
            }
        });
        btnNewButton.setBounds(279, 215, 93, 23);
        contentPane.add(btnNewButton);

        btnNewButton_1 = new JButton("取消");
        btnNewButton_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MainWindow manager = new MainWindow();
                Modify.this.disable();
            }
        });
        btnNewButton_1.setBounds(70, 215, 93, 23);
        contentPane.add(btnNewButton_1);

        setVisible(true);
    }

}

你可能感兴趣的:(2019-08-31 Modify extends JFrame)