The error:
Exception in thread "main" java.lang.NullPointerException
at view.InfoPanel.<init>(InfoPanel.java:32)
at controller.Controller.makeFrame(Controller.java:41 )
at controller.Controller.<init>(Controller.java:25)
at controller.Main.main(Main.java:11)
The code:
package controller; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.*; import javax.swing.*; import view.ControlPanel; import view.InfoPanel; //import view.ProgramView; import view.BoardView; //import model.Program; public class Controller extends JFrame implements ActionListener { private ControlPanel controlpanel; private InfoPanel infopanel; private BoardView boardview; public Controller() { super("Chess Manager"); makeFrame(); makeMenuBar(this); this.pack(); } private void makeFrame(){ setSize(650, 650); setDefaultCloseOperation(EXIT_ON_CLOSE); Container contentpane = super.getContentPane(); contentpane.setLayout(new BorderLayout()); contentpane.setBackground(new Color(204,229,255)); controlpanel = new ControlPanel(this); contentpane.add(controlpanel, BorderLayout.EAST); infopanel = new InfoPanel(this); contentpane.add(infopanel, BorderLayout.SOUTH); boardview = new BoardView(this); contentpane.add(boardview, BorderLayout.WEST); } private void makeMenuBar(Controller controller){ JMenuBar menubar = new JMenuBar(); super.setJMenuBar(menubar); JMenu fileMenu = new JMenu("File"); menubar.add(fileMenu); JMenu editMenu = new JMenu("Edit"); menubar.add(editMenu); JMenu optionMenu = new JMenu("Options"); menubar.add(optionMenu); JMenu extraMenu = new JMenu("Extra"); menubar.add(extraMenu); } private void setupProgram(){ } public void actionPerformed(ActionEvent e){ } }
__________________________________________________ ________________________________
package view; import java.awt.*; import javax.swing.JPanel; import javax.swing.JTextPane; import javax.swing.JTextField; import javax.swing.JTextArea; import javax.swing.BorderFactory; import controller.Controller; import model.Subscription; public class InfoPanel extends JPanel { private JTextField subscriptionbar; private JTextPane fenbar; private JTextArea infobar; private Subscription subscription; public InfoPanel (Controller controller){ setLayout(new GridBagLayout()); setBackground(new Color(204,229,255)); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(10,0,10,0); subscriptionbar = new JTextField(subscription.getSubscription()); gbc.gridy = 0; subscriptionbar .setPreferredSize(new Dimension(500, 25)); subscriptionbar .setBorder(BorderFactory.createLineBorder(Color.BL ACK)); add(subscriptionbar, gbc); fenbar = new JTextPane(); gbc.gridy = 1; fenbar .setPreferredSize(new Dimension(500, 25)); fenbar .setBorder(BorderFactory.createLineBorder(Color.BL ACK)); add(fenbar, gbc); infobar = new JTextArea(); gbc.gridy = 2; infobar .setPreferredSize(new Dimension(500, 150)); infobar .setBorder(BorderFactory.createLineBorder(Color.BL ACK)); infobar .setEditable(false); add(infobar, gbc); } }