// PintyChessBug Written by Seth Carlson import java.awt.*; import java.applet.*; import java.awt.event.*; public class MuteButtons extends Applet { static boolean sIllustrateTheBug = true; // ************************************** CONSTANTS ******************************* private final int MAX_SMALL_WIDTH = 600; // Max width for the game private final int MAX_SMALL_HEIGHT = 500; // Max height for the game // ************************************** VARIABLES ******************************* public Frame myFrame; public Button mac_NameButton = new Button("Set Player Name"); public Button mac_SetTimeControls = new Button("Set Time Controls"); // ********************************** BEGIN CODE ******************************* public String getAppletInfo() {return "PintyChessBug, by S. Carlson";} public void init() { // Variable initialization, image loading, etc. myFrame = new Frame("MuteButtons"); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) { String temp; boolean check; String command = e.getActionCommand(); if (command.compareTo("Set Player Name") == 0) { System.err.println("Set Player Name button pushed..."); } else if (command.compareTo("Set Time Controls") == 0) { System.err.println("Set Time Controls button pushed..."); } } }; /* Set up action listeners and menus */ mac_NameButton.addActionListener(al); mac_SetTimeControls.addActionListener(al); myFrame.setResizable(false); myFrame.setSize(MAX_SMALL_WIDTH, MAX_SMALL_HEIGHT); myFrame.setLocation(300, 300); myFrame.setLayout(null); if (sIllustrateTheBug) myFrame.setVisible(true); // Showing before adding buttons breaks it // Set up buttons // .setBounds(x, y, width, height); mac_NameButton.setBounds(15, 75, 160, 25); myFrame.add(mac_NameButton); mac_SetTimeControls.setBounds(15, 115, 160, 25); myFrame.add(mac_SetTimeControls); if (!sIllustrateTheBug) myFrame.setVisible(true); // It works if show is after the buttons are added else myFrame.repaint(); } }