📄 showrounds.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ShowRounds extends JFrame{
public int count;
public int count2;
public int count3;
public int count4;
public int count5;
public int count6;
public ShowRounds(int c,int c2,int c3,int c4,int c5,int c6){
this.count=c;
this.count2=c2;
this.count3=c3;
this.count4=c4;
this.count5=c5;
this.count6=c6;
/* if(count==0){
count=1;
}*/
getContentPane().setLayout(new BorderLayout());
getContentPane().add(new JLabel("显示成绩情况",SwingConstants.CENTER),
BorderLayout.NORTH);
getContentPane().add(new showout(count,count2,count3,count4,
count5,count6),BorderLayout.CENTER);
}
/* public static void main(String[] args){
ShowRounds frame=new ShowRounds();
frame.setSize(450,350);
frame.setVisible(true);
}*/
}
class showout extends JPanel{
public int count;
public int count2;
public int count3;
public int count4;
public int count5;
public int count6;
public showout(){
}
public showout(int c,int c2,int c3,int c4,int c5,int c6){
this.count=c;
this.count2=c2;
this.count3=c3;
this.count4=c4;
this.count5=c5;
this.count6=c6;
this.setBackground(Color.pink);
}
protected void paintComponent(Graphics g){
super.paintComponent(g);
if(0==count){
g.setColor(Color.black);
g.drawString("本班没有人参加此课程",150,150);
}
else{
int x=getWidth()/9;
int y=getHeight()/9;
int r=getHeight()*4/5;
int a1=360*count2/count;
int a2=a1+360*count3/count;
int a3=a2+360*count4/count;
int a4=a3+360*count5/count;
g.setColor(Color.cyan);
g.fillArc(x,y,r,r,0,360*count2/count);
g.setColor(Color.magenta);
g.fillArc(x,y,r,r,a1,360*count3/count);
g.setColor(Color.lightGray);
g.fillArc(x,y,r,r,a2,360*count4/count);
g.setColor(Color.green);
g.fillArc(x,y,r,r,a3,360*count5/count);
g.setColor(Color.white);
g.fillArc(x,y,r,r,a4,360-a4);
g.setColor(Color.blue);
g.drawString("参加此考试有"+count+"人",30,30);
}
g.setColor(Color.magenta);
g.fillRect(340,150,10,10);
g.setColor(Color.cyan);
g.fillRect(340,170,10,10);
g.setColor(Color.lightGray);
g.fillRect(340,190,10,10);
g.setColor(Color.green);
g.fillRect(340,210,10,10);
g.setColor(Color.white);
g.fillRect(340,230,10,10);
g.setColor(Color.black);
g.drawString("<60",360,160);
g.drawString("60-70",360,180);
g.drawString("70-80",360,200);
g.drawString("80-90",360,220);
g.drawString("90-100",360,240);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -