不知大家有什么高见啊,来帮我看看吧,顺便指导一下啊
import java.awt.*;import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Wangpeng extends JFrame implements ChangeListener
{
private JTextField text_char;
private JSpinner spinner;
private Timer timer;
public Wangpeng ()
{
super("滚动字");
this.setBounds(240,240,400,210);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(new GridLayout(2,1));
text_char=new JTextField("Hello!");
this.getContentPane().add(text_char);
JPanel panel=new JPanel();
this.getContentPane().add(panel);
spinner=new JSpinner();
spinner.setValue(50);
panel.add(spinner);
spinner.addChangeListener(this);
timer=new Timer(delay ,this);
timer.start();
this.setVisible(true);
}
public void stateChanged(ChangeEvent e)
{
text_char.setDelay(Integer.parseInt(""+spinner.getValue()));
}
public static void main(String args[])
{
new Wangpeng();
}
}
说两处有问题啊text_char.setDelay(Integer.parseInt(""+spinner.getValue()));
还有timer=new Timer(delay ,this);
timer.start();
这两处有问题啊
就是用spinner 控件来控制滚动字hello的移动速度,用timer来实现hello的滚动 --------------------编程问答-------------------- 看来大家也是江郎才尽啊 --------------------编程问答-------------------- Timer 第二个参数是一个实现 ActionListener接口的类实例。
补充:Java , Eclipse