📄 drawrectangles1.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -