Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PigPanel extends JPanel
- {
- private JButton rollButton, passButton;
- public PigPanel()
- {
- rollButton = new JButton("Roll");
- rollButton.setPreferredSize(new Dimension(550, 60));
- rollButton.addActionListener(new ButtonListener());
- add(rollButton);
- passButton = new JButton("Pass it!");
- passButton.setPreferredSize(new Dimension(150, 50));
- passButton.addActionListener(new ButtonListener());
- add(rollButton);
- }
- private class ButtonListener implements ActionListener
- {
- public void actionPerformed(ActionEvent event)
- {
- if (event.getSource() == rollButton)
- {
- // do one thing
- }
- else if (event.getSource() == passButton)
- {
- // do another thing
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment