import java.awt.*;
import javax.swing.*;public class a
{
JFrame frame;
Container c;
JTextField t1;
int i;
public a()
{
frame=new JFrame("奇多多");
c=frame.getContentPane();
c.setLayout(null);
t1=new JTextField();
t1.setLocation(30,30);
t1.setSize(100,30);
t1.setText("99");
c.add(t1);
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void aa()
{
while(Integer.parseInt(t1.getText())>0)
{
try
{
Thread.sleep(10);
i=Integer.parseInt(t1.getText());
i-=1;
t1.setText(String.valueOf(i));
}
catch(Exception e)
{} }
}
public static void main(String args[])
{
a wt=new a();
wt.aa();
}
}
import javax.swing.*;public class a
{
JFrame frame;
Container c;
JTextField t1;
int i;
public a()
{
frame=new JFrame("奇多多");
c=frame.getContentPane();
c.setLayout(null);
t1=new JTextField();
t1.setLocation(30,30);
t1.setSize(100,30);
t1.setText("99");
c.add(t1);
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void aa()
{
while(Integer.parseInt(t1.getText())>0)
{
try
{
Thread.sleep(10);
i=Integer.parseInt(t1.getText());
i-=1;
t1.setText(String.valueOf(i));
}
catch(Exception e)
{} }
}
public static void main(String args[])
{
a wt=new a();
wt.aa();
}
}
import javax.swing.*;
//这里可以使用Thread 或者Runnable
public class a extends Thread
{
JFrame frame;
Container c;
JTextField t1;
int i;
public a()
{
frame=new JFrame("奇多多");
c=frame.getContentPane();
c.setLayout(null);
t1=new JTextField();
t1.setLocation(30,30);
t1.setSize(100,30);
t1.setText("99");
c.add(t1);
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void run()
{
while(Integer.parseInt(t1.getText())>0)
{
try
{
Thread.sleep(10);
i=Integer.parseInt(t1.getText());
i-=1;
t1.setText(String.valueOf(i));
}
catch(Exception e)
{}
}
}
public static void main(String args[])
{
a wt=new a();
wt.start();
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
//这里可以使用Thread 或者Runnable
public class a extends Thread implements ActionListener
{
JFrame frame;
Container c;
JTextField t1;
int i;
JButton b1;
public a()
{
frame=new JFrame("奇多多");
c=frame.getContentPane();
c.setLayout(null);
t1=new JTextField();
t1.setLocation(30,30);
t1.setSize(100,30);
t1.setText("99");
b1=new JButton("确定");
b1.setSize(70,30);
b1.setLocation(140,30);
b1.addActionListener(this);
c.add(t1);
c.add(b1);
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void run()
{
while(Integer.parseInt(t1.getText())>0)
{
try
{
Thread.sleep(10);
i=Integer.parseInt(t1.getText());
i-=1;
t1.setText(String.valueOf(i));
}
catch(Exception e)
{}
}
}
public static void main(String args[])
{
new a();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
start();
}
}
}
这回可以加分了吧!!!
经典计算机电子书籍免费下载!
无需注册直接下载,真正的免费!
大量计算机、英语、考研视频学习资料
网址:http://edu.3322.net