import javax
import java
import java
//public class Test
// public static void main(String[] args) {
// Dazi dazi = new Dazi();
// dazi
// }
//}
public class Dazi implements KeyListener
JFrame jf;// 主框架;
JMenuBar mainBar;
Thread t = null;
JPanel jp
JPanel jp
JPanel jp
JLabel jtf;// 顯示得分信息
JMenu fileMenu;
JMenu helpMenu;
JLabel jl
JLabel jl
JLabel jl
JLabel jl
int x[]={
int y[]={
String[][] str
String tempStr=
int flagCount =
int score =
int jibie =
boolean startFlag = false;
public String getstring() {
int x = (int) (
int y = (int) (
int z = (int) (
String str =
return str;
}
public void setFrame() {
jf = new JFrame(
jf
jf
jf
set
jf
jf
// jp
// jl
// jl
// jl
showMenu(); // 設置菜單
showTool(); // 設置工具條
showScore();
jf
//xunhuan();
// jp
}
private void set
String str = getstring();
str
str
jl
str = getstring();
str
str
jl
str = getstring();
str
str
jl
str = getstring();
str
str
jl
}
public void xunHuan(){
while(y[
try {
Thread
} catch (InterruptedException e) {
e
}
for(int i=
y+=jibie;
}
if(!isLive()) {
if(getDisapperStr()
String str = getstring();
str
str
jl
y[
jl
}else if(getDisapperStr()
String str = getstring();
str
str
jl
y[
jl
}else if(getDisapperStr()
String str = getstring();
str
str
jl
y[
jl
}else{
String str = getstring();
str
str
jl
y[
jl
}
//加分
score +=
String scoreStr =
jtf
}else {
if(isOver()) {
for(int i=
y =
}
set
JOptionPane
JOptionPane
return;
}
jl
jl
jl
jl
}
jf
jf
jf
jf
}
}
/**
* 判斷四個串是否存在
* @return 若存在 返回true 否則false
*/
private boolean isLive() {
boolean flag = true;
for(int i=
if(!str
flag = false;
}
}
return flag;
}
private String getDisapperStr() {
String str =
for(int i=
if(!str
str = str
break;
}
}
return str;
}
private boolean isOver() {
boolean overFalg = false;
for(int i=
if(y >=
overFalg = true;
}
}
return overFalg;
}
public void showMenu() {
mainBar = new JMenuBar();
fileMenu = new JMenu(
helpMenu = new JMenu(
// jf
JMenuItem startItem = new JMenuItem(
JMenuItem exitItem = new JMenuItem(
startItem
InputEvent
startItem
new ActionListener() {
public void actionPerformed(ActionEvent e) {
startFlag = true;
//System
}
}
);
exitItem
InputEvent
exitItem
public void actionPerformed(ActionEvent e) {
JOptionPane
JOptionPane
System
}
});
JMenuItem aboutItem = new JMenuItem(
aboutItem
InputEvent
aboutItem
public void actionPerformed(ActionEvent e) {
JOptionPane
JOptionPane
}
});
mainBar
mainBar
fileMenu
fileMenu
helpMenu
jf
}
public void showTool() {
Container contentPane = jf
JToolBar jtb = new JToolBar(); // 設置工具條
jtb
contentPane
mainBar = new JMenuBar();// 定義主菜單
JRadioButton[] buttons = new JRadioButton[
jp
jp
jp
jp
ButtonGroup bg = new ButtonGroup();
JRadioButton b
b
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e
setJibie(
}
}
}
);
bg
jp
JRadioButton b
b
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e
setJibie(
}
}
}
);
bg
jp
JRadioButton b
b
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e
setJibie(
}
}
}
);
bg
jp
JRadioButton b
b
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e
setJibie(
}
}
}
);
bg
jp
JRadioButton b
b
new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e
setJibie(
}
}
}
);
bg
jp
// for (int i =
// buttons = new JRadioButton(
// bg
// jp
// buttons
//
// public void itemStateChanged(ItemEvent e) {
// if(e
// }
// }
// });
// }
jtb
}
public void showScore() {
jp
jp
jtf = new JLabel(
jp
jf
jf
}
public void keyPressed(KeyEvent e) {
tempStr +=e
flagCount ++;
if(flagCount ==
for(int i=
if(tempStr
str
break;
}
}
flagCount =
tempStr =
}
}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
public static void main(String[] args) {
Dazi dazi = new Dazi();
dazi
new Thread(dazi)
}
public void setJibie(int jibie) {
this
}
public void run() {
while (true) {
try {
if(startFlag) {
xunHuan();
startFlag = false;
}
Thread
} catch (InterruptedException e) {
e
}
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26686.html