drawrectangles1.java

来自「学生成绩管理系统:能输入学科」· Java 代码 · 共 57 行

JAVA
57
字号
import java.awt.*;import javax.swing.*;import javax.swing.*;/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author HSM */  public class DrawRectangles1 extends JPanel{    private int[] shu=new int[5];	private int[] temp=new int[5];	public DrawRectangles1(int[] shu){				this.shu=shu;		temp[0]=250-shu[0]*200/25;		temp[1]=250-shu[1]*200/25;		temp[2]=250-shu[2]*200/25;		temp[3]=250-shu[3]*200/25;		temp[4]=250-shu[4]*200/25;	}        @Override	protected void paintComponent(Graphics g){		super.paintComponent(g);		g.drawString("人数",10,20);			g.drawString("25",10,50);			g.drawString("20",10,90);			g.drawString("15",10,130);			g.drawString("10",10,170);			g.drawString("5",10,210);			g.drawString("0",10,250);			g.drawString("<60分",50,265);			g.drawString("60-69分",120,265);			g.drawString("70-79分",190,265);			g.drawString("80-89分",260,265);			g.drawString("≥90分",330,265);						g.setColor(Color.gray);			g.fillRect(30,40,355,210);			g.setColor(Color.orange);			g.fillRect(50,temp[0],35,250-temp[0]);			g.fillRect(120,temp[1],35,250-temp[1]);			g.fillRect(190,temp[2],35,250-temp[2]);			g.fillRect(260,temp[3],35,250-temp[3]);			g.fillRect(330,temp[4],35,250-temp[4]);					}   }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?