?? backchangedialog.java
字號:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BackChangeDialog extends JDialog{
JLabel jT = new JLabel("選擇了蜘蛛");
JPanel jMainPane = new JPanel();
JPanel jBtPane = new JPanel();
JPanel jTPane = new JPanel();
private JLabel jL1 = new JLabel();
private JLabel jL2 = new JLabel();
private JLabel jL3 = new JLabel();
private JLabel jL4 = new JLabel();
private JButton jbt = new JButton("選擇結束");
private int backIndex;
public BackChangeDialog(){
backIndex = 0;
setTitle("J蜘蛛牌背");
setResizable(false);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container c = this.getContentPane();
c.setLayout(new BorderLayout(5,10));
jL1.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear.GIF")));
jL2.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear1.GIF")));
jL3.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear2.GIF")));
jL4.setIcon(new javax.swing.ImageIcon(getClass().getResource("images/rear3.GIF")));
jL1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jT.setText("選擇了蜘蛛");
backIndex=0;
}
});
jL2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jT.setText("選擇了椰樹");
backIndex=1;
}
});
jL3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jT.setText("選擇了海魚");
backIndex=2;
}
});
jL4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jT.setText("選擇了藍天");
backIndex=3;
}
});
jbt.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent e){
setVisible(false);
JOptionPane.showMessageDialog(null,"選擇的信息將在下一輪游戲開始時更新","信息",JOptionPane.INFORMATION_MESSAGE);
}
});
jMainPane.add(jL1);
jMainPane.add(jL2);
jMainPane.add(jL3);
jMainPane.add(jL4);
jBtPane.add(jbt);
jTPane.add(jT);
/* jMainPane.setBackground(new Color(0, 112, 26));
jBtPane.setBackground(new Color(0, 112, 26));
jTPane.setBackground(new Color(0, 112, 26));*/
c.add(jTPane,BorderLayout.NORTH);
c.add(jMainPane,BorderLayout.CENTER);
c.add(jBtPane,BorderLayout.SOUTH);
pack();
// this.getContentPane().setBackground(new Color(0, 112, 26));
this.setVisible(false);
this.setLocation(300,200);
}
public int getBackIndex(){
return backIndex;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -