import java.awt.BorderLayout;
成都创新互联拥有10余年成都网站建设工作经验,为各大企业提供网站设计、成都网站设计服务,对于网页设计、PC网站建设(电脑版网站建设)、手机APP定制开发、wap网站建设(手机版网站建设)、程序开发、网站优化(SEO优化)、微网站、申请域名等,凭借多年来在互联网的打拼,我们在互联网网站建设行业积累了很多网站制作、网站设计、网络营销经验,集策划、开发、设计、营销、管理等网站化运作于一体,具备承接各种规模类型的网站建设项目的能力。
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Date;
import java.util.StringTokenizer;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
/**
* pTitle: Swing日历裤拿/p
* pDescription: 操作日期/p
* @author duxu2004
* @version 1.0.1
*/
class JCalendar extends JPanel{
//动态表示年月日
private int year=0;
private int month=0;
private int day=0;
//主面板
private JPanel Main = new JPanel();
//日面板
private JPanel jPanelDay = new JPanel();
//月面板
private JPanel jPanelMonth = new JPanel();
//年的输入位置
private JTextField Year = new JTextField();
//月锋纯握的输入位置
private JTextField Month = new JTextField();
//减少月份
private JButton MonthDown = new JButton();
//增加月份
private JButton MonthUp = new JButton();
private JPanel jPanelButton = new JPanel();
//减少年份
private JButton YearDown = new JButton();
//增加年份
private JButton YearUp = new JButton();
//显示日期的位置
private JLabel Out = new JLabel();
//中国时区,以后可以从这里扩展可以设置时区的功能
private Locale l=Locale.CHINESE;
//主日历
private GregorianCalendar cal=new GregorianCalendar(l);
//星期面板
private JPanel weekPanel=new JPanel();
//天按钮组
private JToggleButton[] days=new JToggleButton[42];
//天面板
private JPanel Days = new JPanel();
//银庆标示
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private JLabel jLabel3 = new JLabel();
private JLabel jLabel4 = new JLabel();
private JLabel jLabel5 = new JLabel();
private JLabel jLabel6 = new JLabel();
private JLabel jLabel7 = new JLabel();
//当前选择的天数按钮
private JToggleButton cur=null;
//月份天数数组,用来取得当月有多少天
// 1 2 3 4 5 6 7 8 9 10 11 12
private int[] mm={31,28,31,30,31,30,31,31,30,31,30,31};
//空日期构造函数
public JCalendar() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//带日期设置的构造函数
public JCalendar(int year, int month, int day) {
cal.set(year, month, day);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//带日历输入的构造函数
public JCalendar(GregorianCalendar calendar) {
cal=calendar;
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//带日期输入的构造函数
public JCalendar(Date date) {
cal.setTime(date);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//初始化组件
private void jbInit() throws Exception {
//初始化年、月、日
iniCalender();
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createRaisedBevelBorder());
this.setMaximumSize(new Dimension(200, 200));
this.setMinimumSize(new Dimension(200, 200));
this.setPreferredSize(new Dimension(200, 200));
Main.setLayout(new BorderLayout());
Main.setBackground(SystemColor.info);
Main.setBorder(null);
Out.setBackground(Color.lightGray);
Out.setHorizontalAlignment(SwingConstants.CENTER);
Out.setMaximumSize(new Dimension(100, 19));
Out.setMinimumSize(new Dimension(100, 19));
Out.setPreferredSize(new Dimension(100, 19));
jLabel1.setForeground(Color.red);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setText("日");
jLabel2.setForeground(Color.blue);
jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
jLabel2.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel2.setText("六");
jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel3.setText("五");
jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
jLabel4.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel4.setText("四");
jLabel5.setHorizontalAlignment(SwingConstants.CENTER);
jLabel5.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel5.setText("三");
jLabel6.setBorder(null);
jLabel6.setHorizontalAlignment(SwingConstants.CENTER);
jLabel6.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel6.setText("二");
jLabel7.setBackground(Color.lightGray);
jLabel7.setForeground(Color.black);
jLabel7.setBorder(null);
jLabel7.setHorizontalAlignment(SwingConstants.CENTER);
jLabel7.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel7.setText("一");
weekPanel.setBackground(UIManager.getColor("InternalFrame.activeTitleGradient"));
weekPanel.setBorder(BorderFactory.createEtchedBorder());
weekPanel.setLayout(new GridLayout(1,7));
weekPanel.add(jLabel1, null);
weekPanel.add(jLabel7, null);
weekPanel.add(jLabel6, null);
weekPanel.add(jLabel5, null);
weekPanel.add(jLabel4, null);
weekPanel.add(jLabel3, null);
weekPanel.add(jLabel2, null);
MonthUp.setAlignmentX((float) 0.0);
MonthUp.setActionMap(null);
jPanelMonth.setBackground(SystemColor.info);
jPanelMonth.setLayout(new BorderLayout());
jPanelMonth.setBorder(BorderFactory.createEtchedBorder());
Month.setBorder(null);
Month.setHorizontalAlignment(SwingConstants.CENTER);
Month.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
Month_mouseClicked(e);
}
});
Month.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(KeyEvent e) {
Month_keyPressed(e);
}
});
MonthDown.setBorder(null);
MonthDown.setText("\u25C4");
MonthDown.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
MonthDown_actionPerformed(e);
}
});
MonthUp.setBorder(null);
MonthUp.setText("\u25BA");
MonthUp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
MonthUp_actionPerformed(e);
}
});
jPanelButton.setLayout(null);
jPanelButton.setBorder(null);
jPanelButton.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent evt) {
jPanelButtonComponentResized(evt);
}
});
Year.setBorder(BorderFactory.createEtchedBorder());
Year.setMaximumSize(new Dimension(80, 25));
Year.setMinimumSize(new Dimension(80, 25));
Year.setPreferredSize(new Dimension(80, 25));
Year.setHorizontalAlignment(SwingConstants.CENTER);
Year.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
Year_mouseClicked(e);
}
});
Year.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(KeyEvent e) {
Year_keyPressed(e);
}
});
YearDown.setBorder(null);
YearDown.setMaximumSize(new Dimension(16, 16));
YearDown.setMinimumSize(new Dimension(16, 16));
YearDown.setPreferredSize(new Dimension(16, 16));
YearDown.setSize(new Dimension(16, 16));
YearDown.setText("▼");
YearDown.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
YearDown_actionPerformed(e);
}
});
YearUp.setBorder(null);
YearUp.setMaximumSize(new Dimension(16, 16));
YearUp.setMinimumSize(new Dimension(16, 16));
YearUp.setPreferredSize(new Dimension(16, 16));
YearUp.setSize(new Dimension(16, 16));
YearUp.setText("▲");
YearUp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
YearUp_actionPerformed(e);
}
});
jPanelDay.setLayout(new BorderLayout());
Days.setLayout(new GridLayout(6,7));
Days.setBackground(SystemColor.info);
for(int i=0;i42;i++){
days[i]=new JToggleButton();
days[i].setBorder(null);
days[i].setBackground(SystemColor.info);
days[i].setHorizontalAlignment(SwingConstants.CENTER);
days[i].setHorizontalTextPosition(SwingConstants.CENTER);
//days[i].setSize(l,l);
days[i].addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e) {
day=Integer.parseInt(((JToggleButton)e.getSource()).getText());
showDate();
showDays();
}
});
Days.add(days[i]);
}
this.add(Main, BorderLayout.NORTH);
this.add(jPanelDay, BorderLayout.CENTER);
this.add(jPanelMonth, BorderLayout.SOUTH);
Main.add(Year, BorderLayout.CENTER);
Main.add(Out, BorderLayout.WEST);
Main.add(jPanelButton, BorderLayout.EAST);
jPanelButton.add(YearUp);
jPanelButton.add(YearDown);
jPanelDay.add(weekPanel,BorderLayout.NORTH);
jPanelDay.add(Days, BorderLayout.CENTER);
jPanelMonth.add(Month, BorderLayout.CENTER);
jPanelMonth.add(MonthDown, BorderLayout.WEST);
jPanelMonth.add(MonthUp, BorderLayout.EAST);
showMonth();
showYear();
showDate();
showDays();
}
//自定义重画年选择面板
void jPanelButtonComponentResized(java.awt.event.ComponentEvent evt){
YearUp.setLocation(0,0);
YearDown.setLocation(0,YearUp.getHeight());
jPanelButton.setSize(YearUp.getWidth(),YearUp.getHeight()*2);
jPanelButton.setPreferredSize(new Dimension(YearUp.getWidth(),YearUp.getHeight()*2));
jPanelButton.updateUI();
}
//测试用
public static void main(String[] args){
JFrame f=new JFrame();
f.setContentPane(new JCalendar());
f.pack();
//f.setResizable(false);
f.show();
}
//增加年份
void YearUp_actionPerformed(ActionEvent e) {
year++;
showYear();
showDate();
showDays();
}
//减少年份
void YearDown_actionPerformed(ActionEvent e) {
year--;
showYear();
showDate();
showDays();
}
//减少月份
void MonthDown_actionPerformed(ActionEvent e) {
month--;
if(month0) {
month = 11;
year--;
showYear();
}
showMonth();
showDate();
showDays();
}
//增加月份
void MonthUp_actionPerformed(ActionEvent e) {
month++;
if(month==12) {
month=0;
year++;
showYear();
}
showMonth();
showDate();
showDays();
}
//初始化年月日
void iniCalender(){
year=cal.get(Calendar.YEAR);
month=cal.get(Calendar.MONTH);
day=cal.get(Calendar.DAY_OF_MONTH);
}
//刷新月份
void showMonth(){
Month.setText(Integer.toString(month+1)+"月");
}
//刷新年份
void showYear(){
Year.setText(Integer.toString(year)+"年");
}
//刷新日期
void showDate(){
Out.setText(Integer.toString(year)+"-"+Integer.toString(month+1)+"-"+Integer.toString(day));
}
//重画天数选择面板
void showDays() {
cal.set(year,month,1);
int firstDayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int n=mm[month];
if(cal.isLeapYear(year)month==1) n++;
int i=0;
for(;ifirstDayOfWeek-1;i++){
days[i].setEnabled(false);
days[i].setSelected(false);
days[i].setText("");
}
int d=1;
for(;d=n;d++){
days[i].setText(Integer.toString(d));
days[i].setEnabled(true);
if(d==day) days[i].setSelected(true);
else days[i].setSelected(false)
i++;
}
for(;i42;i++){
days[i].setEnabled(false);
days[i].setSelected(false);
days[i].setText("");
}
}
//单击年份面板选择整个年份字符串
void SelectionYear(){
Year.setSelectionStart(0);
Year.setSelectionEnd(Year.getText().length());
}
//单击月份面板选择整个月份字符串
void SelectionMonth(){
Month.setSelectionStart(0);
Month.setSelectionEnd(Month.getText().length());
}
//月份面板响应鼠标单击事件
void Month_mouseClicked(MouseEvent e) {
//SelectionMonth();
inputMonth();
}
//检验输入的月份
void inputMonth(){
String s;
if(Month.getText().endsWith("月"))
{
s=Month.getText().substring(0,Month.getText().length()-1);
}
else s=Month.getText();
month=Integer.parseInt(s)-1;
this.showMe();
}
//月份面板键盘敲击事件响应
void Month_keyPressed(KeyEvent e) {
if(e.getKeyChar()==10)
inputMonth();
}
//年份面板响应鼠标单击事件
void Year_mouseClicked(MouseEvent e) {
//SelectionYear();
inputYear();
}
//年份键盘敲击事件响应
void Year_keyPressed(KeyEvent e) {
//System.out.print(new Integer(e.getKeyChar()).byteValue());
if(e.getKeyChar()==10)
inputYear();
}
//检验输入的年份字符串
void inputYear() {
String s;
if(Year.getText().endsWith("年"))
{
s=Year.getText().substring(0,Year.getText().length()-1);
}
else s=Year.getText();
year=Integer.parseInt(s);
this.showMe();
}
//以字符串形式返回日期,yyyy-mm-dd
public String getDate(){return Out.getText();}
//以字符串形式输入日期,yyyy-mm-dd
public void setDate(String date){
if(date!=null){
StringTokenizer f = new StringTokenizer(date, "-");
if(f.hasMoreTokens())
year = Integer.parseInt(f.nextToken());
if(f.hasMoreTokens())
month = Integer.parseInt(f.nextToken());
if(f.hasMoreTokens())
day = Integer.parseInt(f.nextToken());
cal.set(year,month,day);
}
this.showMe();
}
//以日期对象形式输入日期
public void setTime(Date date){
cal.setTime(date);
this.iniCalender();
this.showMe();
}
//返回日期对象
public Date getTime(){return cal.getTime();}
//返回当前的日
public int getDay() {
return day;
}
//设置当前的日
public void setDay(int day) {
this.day = day;
cal.set(this.year,this.month,this.day);
this.showMe();
}
//设置当前的年
public void setYear(int year) {
this.year = year;
cal.set(this.year,this.month,this.day);
this.showMe();
}
//返回当前的年
public int getYear() {
return year;
}
//返回当前的月
public int getMonth() {
return month;
}
//设置当前的月
public void setMonth(int month) {
this.month = month;
cal.set(this.year,this.month,this.day);
this.showMe();
}
//刷新
public void showMe(){
this.showDays();
this.showMonth();
this.showYear();
this.showDate();
}
}
public class TestJCalendar {
public static void main(String[] args) {
JFrame f=new JFrame();
f.setContentPane(new JCalendar());
f.pack();
//f.setResizable(false);
f.show();
}
}
package com.regex;
import java.io.*;
import java点虐 .URLDecoder;
import java.util.regex.*;
public class Regex {
private int REMARK=0;
private int LOGIC=0;
private int PHYSIC=0;
boolean start=false;
/**
* @param args
*/
public static void main(String[] args) { //测试方法
//磨御 TODO Auto-generated method stub
Regex re=new Regex();
re.regCount("Regex.java");
System.out.println("remark Line: "+re.REMARK);
System.out.println("logic Line: "+re.LOGIC);
System.out.println("physic Line: "+re.PHYSIC);
}/**
* @author BlueDance
* @param s
* @deprecated count
*/
public void regCount(String s){
String url=null;
try {
url=URLDecoder.decode(this.getClass().getResource(s).getPath(),"UTF-8");
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
try {
BufferedReader br=new BufferedReader(new FileReader(new File(url)));
String s1=null;
while((s1=br.readLine())!=null){
PHYSIC++;
if(CheckChar(s1)==1){
REMARK++;
System.out.println("纯注释行:"+s1);
}
if(CheckChar(s1)==2){
LOGIC++;
REMARK++;
System.out.println("非纯注释行:"+s1);
}
if(CheckChar(s1)==3)
LOGIC++;
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}
/**
*
* @param s
* @return int
* @version check s
*/
public int CheckChar(String s){
String s1=null;
if(s!=null)
s1=s.trim();
//System.out.println(regCheck(s1,re));
if(regCheck(s1,"(//.*)")) //判断//开头瞎弯岩的为纯注释行
return 1;
if(regCheck(s1,"(.*[;{})] *//.*)")) //判断不是//开头的非纯注释行
return 2;
if(regCheck(s1,"(//*.*)")){ //判断/*开头的纯注释行
start=true;
return 1;
}
if(regCheck(s1,"(.*[;{})]//*.*)")){ //判闹哗断不是/*开头的非纯注释行
start=true;
return 2;
}
if(regCheck(s1,"(.* */*/)")){ //判断*/结尾的纯注释行
start=false;
return 1;
}
if(regCheck(s1,"(.* */*/.*)")!strCheck(s1)){ //判断不是*/结尾的非纯注释行
if(strCheck(s1)){
start=false;
return 2;
}
}
if(start==true) //状态代码,start即/*开始时start=true*/结束时为false
return 1;
return 3;//ssssllll
}//aeee
/**
*
* @param s
* @param re
* @return boolean
*/
public boolean regCheck(String s,String re){ //正则表达试判断方法
return Pattern.matches(re,s);
}
public boolean strCheck(String s){ //中间有*/的字符判断 此方法最关键
if(s.indexOf("*/")0){
int count=0;
String y[]=s.split("/*/");
boolean boo[]=new boolean[y.length];
for (int i = 0; i y.length-1; i++) {
char c[]=y[i].toCharArray();
for (int j = 0; j c.length; j++) {
if(c[j]=='\\'c[j+1]=='"'){
count++;
}
}
if(count%2==0){
if(countNumber("\"",y[i])%2!=0){
boo[i]=true;
}else{
boo[i]=false;
}
}else{
if(countNumber("\"",y[i])%2==0){
boo[i]=true;
}else{
boo[i]=false;
}
}
}
for(int i=0;iboo.length;i++){
if(!boo[i])
return false;
}
return true;
}
return false;
}
public int countNumber(String s,String y){ //此方法为我前面写的字符串出现次数统计方法,不懂的可以看我前面的文章
int count=0;
String [] k=y.split(s);
if(y.lastIndexOf(s)==(y.length()-s.length()))
count=k.length;
else
count=k.length-1;
if(count==0)
System.out.println ("字符串\""+s+"\"在字符串\""+y+"\"没有出现过");
else
return count;
return -1;
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GoodLucky extends JFrame implements ActionListener{
JTextField tf = new JTextField(); //实例化一个文本域
//设置两个按钮
JButton b1 = new JButton("开始");
JButton b2 = new JButton("停止");
boolean isGo = false;
//构造函数
public GoodLucky(){
b1.setActionCommand("start");//在开始按钮上设置一个动作监听 start
JPanel p = new JPanel(); //实例化一个可视化容器
//将两个按钮添加到可视化容器上面,用add方法
p.add(b1);
p.add(b2);
//在两个按钮上增加监听的属性,自动调用下面的监听处理方法actionPerformed(ActionEvent e),如果要代码有更好的可读性,可用内部类实现动作
//监听处理。
b1.addActionListener(this);
b2.addActionListener(this);
//将停止按钮设置为不可编辑(即不可按的状态)
b2.setEnabled(false);
this.getContentPane().add(tf,"North"); //将上面的文本域放在面板的北方,也就是上面(上北下南左西右东)
this.getContentPane().add(p,"South"); //将可视化容器pannel放在南边,也就是下面
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置用户在此窗体上发起 "close" 时默认执行的操作,参数EXIT_ON_CLOSE是使用 System exit 方法退出应用程序。仅在应用程序中使用
this.setSize(300,200); //设置面板大小,宽和高
this.setLocation(300,300); //设置面板刚开始的出现的位置
Cursor cu = new Cursor(Cursor.HAND_CURSOR); //用指定名称创建一个新的定制光标对象,参数表示手状光标类型
this.setCursor(cu); //为指定的光标设置光标图像,即设置光标图像为上面所创建的手状光标类型
this.setVisible(true); //将面板可视化设置为true,即可视,如果为false,即程序运行时面板会隐藏
tf.setText("welcome you! "); //设置面板的标题为欢迎
this.go(); //调用go方法
}
public void go(){
while(true){ //这里是死循环,也就是说用户不点击停止按钮的话他一直循环出现随机数,直到用户点击停止按钮循环才能推出,具体流程在actionPerformed方法中控制。
if(isGo == true){ //上面所定义的isGo的初始值为false,所以程序第一次到此会跳过
String s = ""; //设置空字符串
for(int j = 1; j = 7;j++){ //产生7个随机数
int i = (int)(Math.random() * 36) + 1;//每个随机数产生方式,这里定义灵活,可以自由定义随机数产生的方式
if(i 10){
s = s + " 0" + i; //如果产生的随机数小于10的话做处理:这里就牵扯到一个重要的概念,简单叙述一下:
/*
当一个字符串与一个整型数项相加的意思是连接,上面的s = s + " 0" + i的意思是字符串s链接0再连接整型i值,而不会导致0和整型的i相加,
产生的效果为s0i,由于s为空字符串(上面定义过的),所以当i小于零时,在个位数前面加上0,比如产生的随机数i为7的话,显示效果为 07.
*/
}else{
s = s + " " + i; //如果产生的随机数比10打的话,那么加上空格显示,即数字和数字之间有个空格
}
//以上循环循环七次,以保证能出现7个随机数
}
tf.setText(s); //将产生的随机数全部显示在文本域上,用文本域对象tf调用它的设置文本的方法setText(String)实现。
}
//以下为线程延迟
try{
Thread.sleep(10); //线程类同步方法sleep,睡眠方法,括号里的单位为ms。
}catch(java.lang.InterruptedException e){
e.printStackTrace(); //异常捕获,不用多说。
}
}
}
//以下是上面设置的事件监听的具体处理办法,即监听时间处理方法,自动调用
public void actionPerformed(ActionEvent e){ //传入一个动作事件的参数e
String s = e.getActionCommand(); //设置字符串s来存储获得动作监听,上面的start
/*
以下这个条件语句块的作用为:用户点击开始后(捕获start,用方法getActionCommand()),将命令触发设置为true,从而执行上面的go方法中的循环体(因为循环体中要求isGo参数为true,而初始为false)。
执行循环快产生随机数,并将开始按钮不可编辑化,而用户只可以使用停止按钮去停止。如果用户按下停止时,也就是没有传入参数“start”的时候,
执行else语句块中的语句,isGo设置为false,将不执行上面go中的循环语句块,从而停止产生随机数,并显示,并且把开始按钮设置为可用,而把
停止按钮设置为不可用,等待用户按下开始再去开始新一轮循环产生随机数。
*/
if(s.equals("start")){ //如果捕获到start,也就是用户触发了动作监听器,那么下面处理
isGo = true; //设置isGo为true
b1.setEnabled(false); //将开始按钮设置为不可用
b2.setEnabled(true); //将停止按钮设置为可用
}else{
isGo = false; //将isGo设置为false,isGo为循环标志位
b2.setEnabled(false); //设置停止按钮为不可用(注意看是b2,b2是停止按钮)
b1.setEnabled(true); //设置开始按钮为可用
}
}
public static void main(String[] args){
new GoodLucky(); //产生类的实例,执行方法
}
}