importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.JOptionPane;
publicclassChessextendsFrame
{
ChessPadchesspad=newChessPad();
Chess()
{
add(chesspad);
chesspad.setBounds(70,90,440,440);
Labellabel=newLabel("clicktopoint,doubled_clicktoremove,rightclicktoback",Label.CENTER);
add(label);
label.setBounds(70,55,440,24);
label.setBackground(Color.orange);
addWindowListener
(
newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
System.exit(0);
}
}
);
setLayout(null);
setVisible(true);
setSize(600,550);
}
publicstaticvoidmain(Stringargs[])
{
Chesschess=newChess();
}
}
classChessPadextendsPanelimplementsMouseListener,ActionListener,FocusListener
{
intx=-1,y=-1,chessColor=1;
Stringblackname="",whitename="";
Buttonbutton=newButton("start");
ButtoninputButton=newButton("input");
TextFieldtext_1=newTextField("blackplease"),
text_2=newTextField(""),//whiteplease
text_3=newTextField("black'name"),
text_4=newTextField("white'name");
ChessPad()
{
add(inputButton);
inputButton.setBounds(35,5,60,26);
inputButton.addActionListener(this);
inputButton.addFocusListener(this);
add(text_3);
text_3.setBounds(115,5,90,24);
text_3.addFocusListener(this);
text_3.setEditable(true);