怎么用java畫弧形
2024-02-15 17:11:33
```java
import java.awt.Color;
import java.awt.GraphicsD;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class DrawArc extends JPanel {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
GraphicsD gd = (GraphicsD) g;
gd.setColor(Color.BLUE);
int x = ;
int y = ;
int width = ;
int height = ;
int startAngle = ;
int arcAngle = ;
gd.drawArc(x, y, width, height, startAngle, arcAngle);
}
public static void main(String[] args) {
JFrame frame = new JFrame("Draw Arc");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(, );
frame.add(new DrawArc());
frame.setVisible(true);
}
}
```
這段代碼將創(chuàng)建個(gè)新的Java窗口,在其中畫個(gè)藍(lán)色的弧形。