1.急求猜数字小游戏代码
急求猜数字小游戏代码
本人是猜喜JAVA语言爱好者,赠送你我的欢源ruby解释器源码源码。
还是码猜钢结构网站源码学学JAVA吧。
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
class Guess extends JFrame implements ActionListener{
int rand;
JLabel label = new JLabel("Enter whole number:");
JLabel label_image = new JLabel( new ImageIcon(".gif"));
JTextField textfield = new JTextField();
JButton button_guess = new JButton("Guess");
JButton button_again = new JButton("Once again");
JPanel panel_north = new JPanel();
JPanel panel_center = new JPanel();
JPanel panel_north_middle = new JPanel();
TextArea textarea = new TextArea(null,喜欢ov5647 源码,,TextArea.SCROLLBARS_BOTH);
//---------------------------------------
Guess(){
this.setSize(,);
this.rand=(int)(Math.random()*);
Container face =this.getContentPane();
face.add(panel_north,"North");
face.add(panel_center);
panel_north.setLayout(new GridLayout(1,3,3,1));
panel_north.add(label);
panel_north.add(textfield);
panel_north.add(button_guess);
panel_north.add(button_again);
panel_center.add(textarea);
panel_center.add(label_image);
button_guess.addActionListener(this);
button_again.addActionListener(this);
this.setVisible(true);
}
//---------------------------------------------
public void actionPerformed(ActionEvent w){
try{
if(w.getSource()==button_guess){
String s=textfield.getText();
int x=Integer.parseInt(s);
if(x==rand){
textarea.append("Congratulate!\n");
}
else if(x>rand){
textarea.append("The number on the height side!\n");
}
else if(x<rand){
textarea.append("The number on the low side!\n");
}
textfield.setText("");
textfield.requestFocusInWindow();
}
else if(w.getSource()==button_again){
textarea.setText("");
rand=(int)(Math.random()*);
}
}catch(Exception e){ }
}
//-----------------------------------------------------------
public static void main(String arg[]){
new Guess().setDefaultLookAndFeelDecorated(true);
}
}
2024-11-25 01:44675人浏览
2024-11-25 01:441584人浏览
2024-11-25 00:30936人浏览
2024-11-25 00:242655人浏览
2024-11-25 00:04167人浏览
2024-11-24 23:572541人浏览
1.区块链金融要学习什么(区块链金融的操作流程)2.javaè¯è¨å¯ä»¥åä»ä¹ï¼3.Ajax高级程序设计作者简介区块链金融要学习什么(区块链金融的操作流程) 有哪些关于
1.CAD修改颜色命令---Lisp代码分享(3)2.CAD显示与隐藏快捷命令---Lisp代码分享(2)3.用arcgis导出shp文件怎么显示的是cad形源代码?CAD修改颜色命令---Lisp代
1.50个c/c++源代码网站2.c语言游戏代码大全收录100多款经典游戏源码)3.C语言爱心代码,C语言爱心代码大全4.有没有300行左右的C语言课程设计的源代码50个c/c++源代码网站 在编