日期:2014-05-20 浏览次数:20724 次
import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Test73 { public static void main(String[] args) { // TODO Auto-generated method stub JFrame frame = new DrawFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } class DrawFrame extends JFrame { public DrawFrame() { // TODO Auto-generated constructor stub setTitle("DrawArc"); setSize(200, 200); add(new DrawPanel()); } } class DrawPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.draw(new Arc2D.Double(40, 50, 100, 50, 0, 60, Arc2D.OPEN)); g2.draw(new Arc2D.Double(40, 50, 100, 50, 120, 60, Arc2D.OPEN)); g2.draw(new Arc2D.Double(40, 50, 100, 50, 240, 60, Arc2D.OPEN)); /*g2.draw(new Arc2D.Double(40, 50, 100, 50, 0, 60, Arc2D.PIE)); g2.draw(new Arc2D.Double(40, 50, 100, 50, 120, 60, Arc2D.PIE)); g2.draw(new Arc2D.Double(40, 50, 100, 50, 240, 60, Arc2D.PIE));*/ } }