Loading src/main/java/ch14/MyGui.java +17 −5 Changes for src/main/java/ch14/MyGui.java: 17 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -4,15 +4,27 @@ import javax.swing.*; import java.awt.event.*; class MyGui implements ActionListener { private JButton colorButton; private JButton labelButton; private JFrame frame; private JLabel label; // lots of code here and then: // declare a bunch of instance variables here public void go() { // build gui colorButton = new JButton(); labelButton = new JButton(); colorButton.addActionListener(this); labelButton.addActionListener(this); // more gui code here ... } public void actionPerformed(ActionEvent event) { if (event.getSource() == colorButton) { frame.repaint(); } else { label.setText("That hurt!"); } // public void actionPerformed(ActionEvent event) { // label.setText("That hurt!"); // } } } Loading
src/main/java/ch14/MyGui.java +17 −5 Changes for src/main/java/ch14/MyGui.java: 17 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -4,15 +4,27 @@ import javax.swing.*; import java.awt.event.*; class MyGui implements ActionListener { private JButton colorButton; private JButton labelButton; private JFrame frame; private JLabel label; // lots of code here and then: // declare a bunch of instance variables here public void go() { // build gui colorButton = new JButton(); labelButton = new JButton(); colorButton.addActionListener(this); labelButton.addActionListener(this); // more gui code here ... } public void actionPerformed(ActionEvent event) { if (event.getSource() == colorButton) { frame.repaint(); } else { label.setText("That hurt!"); } // public void actionPerformed(ActionEvent event) { // label.setText("That hurt!"); // } } }