【发布时间】:2011-04-21 17:02:30
【问题描述】:
我正在尝试获得选框效果(与 html 中的效果相同)。但是我无法使用此代码执行此操作。如何改进此代码以获得选取框效果?
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
class tester {
JLabel l;
tester() {
JFrame fr=new JFrame();
JPanel p=new JPanel();
l=new JLabel("");
fr.add(p);
p.add(l);
fr.setVisible(true);
fr.setSize(400,400);
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void MarqueeEffect() {
ActionListener ac = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
l.setText("To action alone hast thou a right and never at all to its fruits let not the fruits of action be thy motive; neither let there be in thee any attachment to inaction");
}
};
new Timer(2000,ac).start();
}
public static void main(String args[]) {
tester t=new tester();
t.MarqueeEffect();
}
}
【问题讨论】:
-
这是作业,不是吗?你试过什么?