今天路过一家商店看到滚动的显示屏,就做了这个很简单又好玩的程序,用java实现字符串滚动显示。O(∩_∩)O
下面是源代码:
package main.slidetext;
<pre name="code" class="java">package main.slidetext;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SlideText extends JFrame{
private static final long serialVersionUID = 4171454850759140121L;
private JPanel text;
private static String str = "Welcome! This is for 'SlideText' test! "; // 显示文本
private int x = 10;
public SlideText() {
setTitle("Slide Text");
Dimension src = Toolkit.getDefaultToolkit().getScreenSize();