如题,如果有的话,应该怎么用呢?
import java.awt.*;
import java.awt.event.*;
import javax.swing.Timer;
import javax.swing.*;
class SS extends JFrame implements ActionListener{
JButton b1,b2;
JLabel a;
Timer t;
public SS(){
t=new Timer(1000,this);
b1=new JButton("开始");
b2=new JButton("停止");
a=new JLabel("我可以闪烁");
b1.addActionListener(this);
b2.addActionListener(this);
a.addActionListener(this);
add(a);add(b1);add(b2);
setVisible(true);
setSize(200,200);
setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1)
{t.start();
a.setVisible(false);}
else if(e.getSource()==b2)
t.stop();
else if(e.getSource()==a)
{
if(a.isVisible()==true)
a.setVisible(false);
else a.setVisible(true);
}
}
}
public class shanshuo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SS s=new SS();
}
}
这是我写的程序,想让那个标签闪烁,求大神指教~
import java.awt.*;
import java.awt.event.*;
import javax.swing.Timer;
import javax.swing.*;
class SS extends JFrame implements ActionListener{
JButton b1,b2;
JLabel a;
Timer t;
public SS(){
t=new Timer(1000,this);
b1=new JButton("开始");
b2=new JButton("停止");
a=new JLabel("我可以闪烁");
b1.addActionListener(this);
b2.addActionListener(this);
a.addActionListener(this);
add(a);add(b1);add(b2);
setVisible(true);
setSize(200,200);
setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1)
{t.start();
a.setVisible(false);}
else if(e.getSource()==b2)
t.stop();
else if(e.getSource()==a)
{
if(a.isVisible()==true)
a.setVisible(false);
else a.setVisible(true);
}
}
}
public class shanshuo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SS s=new SS();
}
}
这是我写的程序,想让那个标签闪烁,求大神指教~
