Alright, so I'm getting this exception when running my program (it compiles fine).
The first 2, I'm not sure what it's referencing exactly as I dont have a line 410 or 1086.
Line 62 is commenting.
Line 189, is the header for my main method.
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ColorFactory extends JFrame { private final int WINDOW_WIDTH = 500; private final int WINDOW_HEIGHT = 300; private JPanel topPanel; private JPanel bottomPanel; private JPanel centerPanel; private JLabel labelMessage; private JButton red; private JButton orange; private JButton yellow; private ButtonGroup radioButtonGroup; private JRadioButton green; private JRadioButton blue; private JRadioButton cyan; /** The constructor. */ public ColorFactory() { // This is going to call the super constructor. super("Color Factory"); // Setting the title of the window setTitle("Color Factory"); // Setting the size of the window based on our constants. setSize (WINDOW_WIDTH, WINDOW_HEIGHT); // Setting it to exit the program when we close it. setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // Setting our layout setLayout(new BorderLayout()); // These methods build the panels. buildTopPanel(); buildBottomPanel(); // Creating the center panel. centerPanel = new JPanel(); // Adding panel add(centerPanel, BorderLayout.CENTER); // Adding labels centerPanel.add(labelMessage); // The message on the label. labelMessage = new JLabel("The top buttons will change the anel color and" + "the bottom radio buttons change the text color."); setVisible(true); } private void buildTopPanel() { topPanel = new JPanel(); add(topPanel, BorderLayout.NORTH); topPanel.setBackground(Color.WHITE); // Creating the colored buttons. red = new JButton("Red"); orange = new JButton("Orange"); yellow = new JButton("Yellow");; // Coloring the backgrounds of those buttons. red.setBackground(Color.RED); orange.setBackground(Color.ORANGE); yellow.setBackground(Color.YELLOW); // The action listeners red.addActionListener(new ButtonListener()); orange.addActionListener(new ButtonListener()); yellow.addActionListener(new ButtonListener()); // Adding the buttons topPanel.add(red); topPanel.add(orange); topPanel.add(yellow); } private void buildBottomPanel() { bottomPanel=new JPanel(); add(bottomPanel, BorderLayout.SOUTH); // Setting the background color. bottomPanel.setBackground(Color.WHITE); // Creating the buttons for this panel. green=new JRadioButton("Green"); blue=new JRadioButton("Blue"); cyan=new JRadioButton("Cyan"); // Setting the foreground color. green.setForeground(Color.GREEN); blue.setForeground(Color.BLUE); cyan.setForeground(Color.CYAN); // Button grouping radioButtonGroup=new ButtonGroup(); radioButtonGroup.add(green); radioButtonGroup.add(blue); radioButtonGroup.add(cyan); // The action listeners green.addActionListener(new RadioButtonListener()); blue.addActionListener(new RadioButtonListener()); cyan.addActionListener(new RadioButtonListener()); // Adding these buttons bottomPanel.add(green); bottomPanel.add(blue); bottomPanel.add(cyan); } private class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(e.getSource() == red) { centerPanel.setBackground(Color.RED); } else if(e.getSource() == orange) { centerPanel.setBackground(Color.ORANGE); } else if(e.getSource() == yellow) { centerPanel.setBackground(Color.YELLOW); } } } private class RadioButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(e.getSource()==green) { labelMessage.setForeground(Color.GREEN); } else if (e.getSource()==blue) { labelMessage.setForeground(Color.BLUE); } else if (e.getSource()==cyan) { labelMessage.setForeground(Color.CYAN); } } } public static void main(String [] args) { new ColorFactory(); } }
Maybe I'm misunderstanding the exception, but I can't seem to figure out why this exception is happening.