应该是哪里需要写个repaint的代码吧?或是别的?代码如下:
public class MP3 implements KeyListener {
public static void main(String[] args) {
theApp = new MP3();
String msg = null;
if (args[0].charAt(0) == '-')
msg = args[0].substring(1, args[0].length() - 1 frame = new FontFrame(msg);
frame.addKeyListener(theApp); 
}
         public void keyTyped(KeyEvent e) { }
public void keypressed(KeyEvent e) { ........}
public void keyReleased(KeyEvent e) { } private static FontFrame frame;
private static MP3 theApp;
}
class FontFrame extends JFrame {
public FontFrame(String message) {

setTitle("MP3");
this.message = message;
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

panel = new FontPanel(message);
add(panel);
}
         private String message;
public static final int DEFAULT_WIDTH = 800;
public static final int DEFAULT_HEIGHT = 600;
private FontPanel panel = null;
}
class FontPanel extends JPanel {
public FontPanel(String msg) {
row = col = 0;
message = msg;
color = Color.GRAY;
fontSize = 20;
} public void paintComponent(Graphics g) {
super.paintComponent(g);
                  /////绘图操作
                  .........
                  g2.drawString(message, (int) x, (int) baseY);
                  .........
         }
}