📄 drawarcdemo.java
字号:
import javax.swing.*;import java.awt.Graphics;import java.awt.Color;public class DrawArcDemo extends JFrame { public DrawArcDemo() { super("绘制圆弧"); this.getContentPane().add(new ArcPanel()); setSize(300, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { DrawArcDemo dad = new DrawArcDemo(); dad.setVisible(true); }}class ArcPanel extends JPanel { public void paintComponent(Graphics g) { int arcArray[] = { 30, 45, 60, 90, 135}; int start = 0; Color colorArray[] = { Color.green, Color.red, Color.blue, Color.yellow, Color.orange}; g.drawRect(getSize().width / 2 - 100, getSize().height / 2 - 100, 200, 200); for (int i = 0; i < arcArray.length; i++) { g.setColor(colorArray[i]); g.fillArc(getSize().width / 2 - 100, getSize().height / 2 - 100, 200, 200, start, arcArray[i]); start += arcArray[i]; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -