我正在创建一个applet,只想更改位于applet顶部的文本,目前它显示的是“Applet Viewer:Tetris”。我该如何更改?
import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
public class Tetris extends Applet {
public void init() {
setSize(250, 500);
JPanel grid = new JPanel();
grid.setSize(250,500);
add(grid, BorderLayout. CENTER);
}
}
答案 0 :(得分:2)
尝试这是否适合您..
import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
public class Tetris extends Applet {
public void init() {
Frame title = (Frame)this.getParent().getParent();
title.setTitle("New Title");
setSize(250, 500);
JPanel grid = new JPanel();
grid.setSize(250,500);
add(grid, BorderLayout. CENTER);
}
}