import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestSw extends JFrame {
public static void main(String[] args) {
new TestSw();
}
public TestSw(){
super("Test");
this.setSize(new Dimension(400,300));
this.setContentPane(new Mypane());
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
class Mypane extends JPanel{
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.red);
g.setXORMode(Color.white);
g.drawArc(20, 20, 100, 100, 0, 360); //此方法将画一个直径100的圆.红色.
}
}
} |
|