[求助]麻烦请问一下大家Graphics这个类的问题???
package com.sina.www.lx;import java.
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Panel;
import javax.swing.DebugGraphics;
import javax.swing.JFrame;
public class TestC {
TestC()
{
JFrame jf = new JFrame("我的窗口");
jf.setBounds(200, 200,300,300);
jf.setResizable(false);
jf.setVisible(true);
Graphics g = new DebugGraphics();
g.drawLine(200, 200,255,255);
Panel p = new Panel();
p.add(g);
jf.add(p);
}
public static void main(String[] args)
{
new TestC();
}
}
麻烦大家,我想在窗体中画一条线.但是好象p.add(g)出现错误了..
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method add(Component) in the type Container is not applicable for the arguments (Graphics)
at com.sina.www.lx.TestC.<init>(TestC.java:22)
at com.sina.www.lx.TestC.main(TestC.java:28)
请问一下大家,如何把Graphics添加到窗体中显示出来??谢谢了!!~