[img][/img]package com.itheima;
import java.awt.*;
import javax.swing.*;
public class Haha extends JFrame{
private JTextField wbk;
private JPasswordField mmk;
private JLabel bq1,bq2;
private JPanel mb1,mb2,mb3;
private JButton an1,an2;
public Haha(){
mb1=new JPanel();
mb2=new JPanel();
mb3=new JPanel();
wbk=new JTextField(10);
mmk=new JPasswordField(10);
bq1=new JLabel("username");
bq2=new JLabel("password");
an1=new JButton("login");
an1=new JButton("unlogin");
this.setLayout(new GridLayout(3,1));
mb1.add(bq1);mb1.add(wbk);
mb2.add(bq2);mb2.add(mmk);
mb3.add(an1);mb3.add(an2);
this.add(mb1);
this.add(mb2);
this.add(mb3);
this.setTitle("lgoingwindow");
this.setSize(300,300);
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
new Haha();
}
}
Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1090)
at java.awt.Container.add(Container.java:410)
at com.itheima.Haha.<init>(Haha.java:24)
at com.itheima.Haha.main(Haha.java:35)
|