import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.IOException;
public class ReversiApplet extends Applet {
BorderLayout borderLayout = new BorderLayout();
Panel topPanel = new Panel();
FlowLayout flowLayout = new FlowLayout();
Button blackButton = new Button();
Button whiteButton = new Button();
Label statusLabel = new Label();
ReversiBoard board = new ReversiBoard(statusLabel,"couchpotato.net");
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(borderLayout);
topPanel.setLayout(flowLayout);
blackButton.setLabel("Start as Black");
blackButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
blackButton_actionPerformed(e);
}
});
whiteButton.setLabel("Start as White");
whiteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
whiteButton_actionPerformed(e);
}
});
statusLabel.setText("Please choose to play black or white");
this.setFont(new java.awt.Font("Dialog", 1, 12));
this.add(topPanel, BorderLayout.NORTH);
topPanel.add(blackButton, null);
topPanel.add(whiteButton, null);
this.add(board, BorderLayout.CENTER);
this.add(statusLabel, BorderLayout.SOUTH);
}
void whiteButton_actionPerformed(ActionEvent e) {
try {
board.connectAsColor(2);
}
catch (IOException ex) {
statusLabel.setForeground(Color.red);
statusLabel.setText(ex.toString());
}
}
void blackButton_actionPerformed(ActionEvent e) {
try {
board.connectAsColor(1);
}
catch (IOException ex) {
statusLabel.setForeground(Color.red);
statusLabel.setText(ex.toString());
}
}
}