求java大佬,我这样设置界面怎么加背景图片呀

public class LoginForm extends JFrame {

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

    登录界面设计

*/
public LoginForm() {
    super();
    getContentPane().setLayout(null);
    setBounds(100, 100, 399, 253);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("登录界面");

    final JLabel label_1 = new JLabel();
    label_1.setText("用户编号:");
    label_1.setBounds(53, 49, 80, 27);
    getContentPane().add(label_1);

    final JLabel label_2 = new JLabel();
    label_2.setText("密  码:");
    label_2.setBounds(53, 104, 53, 27);
    getContentPane().add(label_2);

    final JTextField tf = new JTextField(10);
    tf.setBounds(123, 49, 185, 27);
    getContentPane().add(tf);

    final JPasswordField ps = new JPasswordField(15);
    ps.setBounds(125, 104, 183, 27);
    getContentPane().add(ps);

    final JButton button = new JButton();
    button.setText("登录");
    button.setBounds(56, 159, 106, 28);
    getContentPane().add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stub
            loginTip(tf,ps);
        }
    });
    final JButton button_1 = new JButton();
    button_1.setText("退出");
    button_1.setBounds(203, 159, 106, 28);
    getContentPane().add(button_1);
    button_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {// TODO Auto-generated method stub
            dispose();
            System.exit(0);
        }
    });
}

你可能感兴趣的:(笔记)