Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JPanel;
- public class ButtonPanel extends JPanel{
- public static final int HEIGHT = 100;
- public static final int WIDTH = 300;
- public JButton newG, exitG, rankG;
- private JPanel buttonPanel;
- public ButtonPanel() {
- newG = new JButton("New Game");
- exitG = new JButton("Exit");
- rankG = new JButton("Ranking");
- newG.addActionListener((ActionListener) this);
- exitG.addActionListener((ActionListener) this);
- rankG.addActionListener((ActionListener) this);
- buttonPanel = this;
- setLayout(new FlowLayout());
- setPreferredSize(new Dimension(WIDTH, HEIGHT));
- add(newG);
- add(exitG);
- add(rankG);
- }
- class NewGButton extends JButton implements ActionListener {
- NewGButton() {
- addActionListener(this);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- buttonPanel.setBackground(Color.GREEN);
- }
- }
- class ExitGButton extends JButton implements ActionListener {
- ExitGButton() {
- addActionListener(this);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- }
- }
- class RankGButton extends JButton implements ActionListener {
- RankGButton() {
- addActionListener(this);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement