JAVA: Swing JButton componnent (NullPointerException)
问题 I am trying to show text - "You pressed Button" when you pressed one of buttons. I am getting an NullPointerException . I have initialized the buttons inside the constructor of the class and after initialization, I called the following method from main() . Here is the code: import java.awt.event.*; import javax.swing.*; import java.awt.*; public class ButtonDemo implements ActionListener{ JLabel jlab; ButtonDemo(){ JFrame jfrm = new JFrame("A Button Example"); jfrm.setLayout(new FlowLayout())