请问 html 的<marquee>标记能应用于jLabel 中吗?~~~ 我是初学者,想在jLabel中做个滚动字幕。不知道<marquee>能应用于jLabel中吗?如果能,请给出代码。如果不能,请帮着解决。谢谢了!!(一定要给出代码哦~~~~) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class rolllabel extends JFrame { private static final long serialVersionUID = -1L; private JPanel pane = null; private MoveLabel label = null; public rolllabel() { super("Test"); pane = new JPanel(); label = new MoveLabel("带有滚动效果的标签"); pane.add(label); this.getContentPane().add(pane); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(300, 200); this.setVisible(true); } public static void main(String args[]) { new rolllabel(); } /** * 带有滚动效果的Label标签,可继续拓展很多特效,例如颜色变换、速度变换等 */ private class MoveLabel extends JLabel implements Runnable { private static final long serialVersionUID = 1891684760189602720L; private String text = null; private Thread thread = null; private int x = 0; private int w = 0, h = 0; public MoveLabel(String text) { super(text); this.text = text; thread = new Thread(this); thread.start(); } public String getText() { return text; } public void setText(String text) { super.setText(text); this.text = text; } protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(this.getBackground()); g.fillRect(0, 0, w = this.getWidth(), h = this.getHeight()); g.setColor(this.getForeground()); g.setFont(this.getFont()); g.drawString(text, x, h - 2); } public void run() { while (true) { x -= 2; if (x < -w) { x = w; } this.repaint(); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } } }} 这个我看过,是转帖吗。不过谢谢你!private MoveLabel label = null; 我定义时报错。 Properties类的使用问题 java怎么读取数据库里的所有表名? JAVA 的API的问题? 本站愿为大家提供交流场所 课程快学完了 以后怎样提高自己? 弟兄们,进来探讨一个小技术问题. 大家知道一个字符串例如:"aa;bb;cc;"怎么把它分割出来吗? 怎么改变JTextField的显示样式 一个函数需要多个返回值,大家是如何处理的? 以下是我连sql server2000的代码,为什么老是不对,各位多指教 java.util.Date java实现telnet功能
super("Test");
pane = new JPanel();
label = new MoveLabel("带有滚动效果的标签");
pane.add(label);
this.getContentPane().add(pane);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300, 200);
this.setVisible(true);
} public static void main(String args[]) {
new rolllabel();
} /**
* 带有滚动效果的Label标签,可继续拓展很多特效,例如颜色变换、速度变换等
*/
private class MoveLabel extends JLabel implements Runnable { private static final long serialVersionUID = 1891684760189602720L; private String text = null; private Thread thread = null; private int x = 0; private int w = 0, h = 0; public MoveLabel(String text) {
super(text);
this.text = text;
thread = new Thread(this);
thread.start();
} public String getText() {
return text;
} public void setText(String text) {
super.setText(text);
this.text = text;
} protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(this.getBackground());
g.fillRect(0, 0, w = this.getWidth(), h = this.getHeight());
g.setColor(this.getForeground());
g.setFont(this.getFont());
g.drawString(text, x, h - 2);
} public void run() {
while (true) {
x -= 2;
if (x < -w) {
x = w;
}
this.repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}}
private MoveLabel label = null; 我定义时报错。