?? localgameinitdialog.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* this class will show dialog, it sets up the local game
*
*/
class LocalGameInitDialog extends JDialog
{
JLabel lb1 = new JLabel("請輸入黑色玩家姓名:");
JLabel lb2 = new JLabel("請輸入白色玩家姓名:");
JTextField tf1 = new JTextField(10);
JTextField tf2 = new JTextField(10);
JButton bn1 = new JButton("確定");
JButton bn2 = new JButton("取消");
JTextField tf = new JTextField(10);
boolean dialogResult;
public int totalSeconds;
public LocalGameInitDialog(JFrame parent, int w, int h)
{
super(parent, "初始化本地游戲", true);
setSize(w, h);
setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new GridLayout(3, 2));
p.add(lb1);
p.add(tf1);
p.add(lb2);
p.add(tf2);
p.add(new JLabel("下棋總時間"));
p.add(tf);
tf.setText("600");
add("North", p);
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(bn1);
p1.add(bn2);
add("South", p1);
bn1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
try{
totalSeconds = Integer.parseInt(tf.getText());
dialogResult = true;
}
catch(NumberFormatException ex)
{
System.out.println("Parse Integer Error!");
}
finally{
setVisible(false);
}
}
});
bn2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
dialogResult = false;
setVisible(false);
}
});
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
});
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -