The Graphics class is the abstract base class for all graphics contexts that allow an application to draw onto components that are realized on various devices, as well as onto off-screen images.
public abstract class StaticOne { /** * */ public StaticOne() { super(); // TODO Auto-generated constructor stub } public static void sayHello() { System.out.println("hello, i am from a static method of a static class"); }}public class Hello { /** * */ public Hello() { super(); StaticOne.sayHello(); } public static void main(String[] args) { new Hello(); } }output: hello, i am from a static method of a static class
好像是用的Graphics2D的对象画的
可是我没有引如Graphics2D他也能实现画线功能啊.
你在你的Paint方法中看看 public void paint(Graphics g) { g.drawString(g.getClass().getName(),50,50); g.drawLine(10,10,85,98); }你就会发现真正的Graphics的实现类是在什么地方,
*
*/
public StaticOne() {
super();
// TODO Auto-generated constructor stub
}
public static void sayHello() {
System.out.println("hello, i am from a static method of a static class");
}}public class Hello { /**
*
*/
public Hello() {
super();
StaticOne.sayHello();
} public static void main(String[] args) {
new Hello();
}
}output:
hello, i am from a static method of a static class
public void paint(Graphics g)
{
g.drawString(g.getClass().getName(),50,50);
g.drawLine(10,10,85,98);
}你就会发现真正的Graphics的实现类是在什么地方,