帮你修改了下
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class MyFrame1 extends JFrame {
private JLabel label = new JLabel();
String[] str = { "电子系", "软件系", "国贸系", "数码媒体系", "计算机系", "基础部" };
public void createFrame() {
JFrame jf = new JFrame();
Container con = jf.getContentPane();
con.add(label);
jf.setSize(150, 300);
jf.setVisible(true);
}
class MyThread extends Thread {
public void run() {
int x = 0;
createFrame();
//要让线程一直执行必须保证其死循环。
while (x < str.length) {
label.setText(str[x]);
try {
MyThread.sleep(1000);
x++;
if (x == str.length)
x = 0;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public void start() {
new MyThread().start();
}
public static void main(String args[]) {
new MyFrame1().start();
}
}
x