📄 stat.java
字号:
/* * Stat.java * * Created on 2005年10月29日, 上午10:36 *//** * * @author isaac */import javax.swing.*;import java.awt.event.*;import java.awt.*;public class Stat extends JDialog { /** Creates a new instance of Stat */ public Stat(StuFrame sf) { super(sf,"成绩分布统计对话框",true); setSize(400,300); owner=sf; a= Math.round(owner.statArr[0]*3.6f); b=Math.round(owner.statArr[1]*3.6f); c=Math.round(owner.statArr[2]*3.6f); d=Math.round(owner.statArr[3]*3.6f); setContentPane(new StatPanel()); } class StatPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponents(g); g.setColor(Color.YELLOW); g.fillArc(x,y, w, w,0,a);//绘制饼图的"优秀"弧断 g.fillRect(190, 40, 10, 10); g.setColor(Color.GREEN); g.fillArc(x,y, w, w,a,b);//绘制饼图的"良好"弧断 g.fillRect(190,90, 10, 10); g.setColor(Color.BLUE); g.fillArc(x,y, w, w,a+b,c);//绘制饼图的"中等"弧断 g.fillRect(190,140, 10, 10); g.setColor(Color.RED); g.fillArc(x,y, w, w,a+b+c,d);//绘制饼图的"不及格"弧断 g.fillRect(190,190, 10, 10); g.setColor(Color.BLACK); g.drawString("成绩优秀(100-90)人数占"+Math.round(owner.statArr[0]*100)/100.0+"%",200,50); g.drawString("成绩良好(89-75)人数占"+Math.round(owner.statArr[1]*100)/100.0+"%",200,100); g.drawString("成绩中等(74-60)人数占"+Math.round(owner.statArr[2]*100)/100.0+"%",200,150); g.drawString("成绩不及格(59-0)人数占"+Math.round(owner.statArr[3]*100)/100.0+"%",200,200); } } int a,b,c,d;//分布弧断 int x=20; int y=50; int w=160; StuFrame owner;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -