我的代码如下:
package accp;/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import java.awt.*;
import javax.swing.*;
class FontsPanels extends JPanel 
{
public void paintComponent(Graphics g)
{
String quote="当前字体.";
Font f=new Font("华文新魏",Font.ITALIC,10);
g.setFont(f);
g.drawString(quote,20,20);
}
}
class FontFrames extends JFrame
{
public FontFrames()
{
setTitle("test");
setSize(300,200);
Container countPane=getContentPane();
countPane.add(new FontsPanels());
}
}
public class FontsPanel
{
public static void main(String[] args)
{
JFrame frame=new FontFrames();
frame.show();
}
}
我是想把字符串以指定的形式在窗口中显示出来,为什么窗口是黑屏呢?标题“test”倒是能显示出来,这是怎么回事呢?