charge.java

来自「这是一个在linux环境下」· Java 代码 · 共 50 行

JAVA
50
字号
package fr.umlv.projet.fenetre.preformance;

import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;
/** 
 *  This class is used to display the "Charge dediee" in the Panel 
 *  {@link fr.umlv.projet.fenetre.preformance.Preformance Preformance}.
 * @author HUANG Wei & Ma Xiao Jun
 * 
 */
public class Charge extends JPanel {
	private int Total = 0;
	private int Limite = 0;
	private int Pic = 0;
	private int w = 0;
	private int h = 0;
	
	protected@Override void paintComponent(Graphics graphic){
		Graphics2D g = (Graphics2D)graphic; 
		super.paintComponent(g);
		w = this.getWidth();
		h = this.getHeight();
		g.drawString("Total",5,15);
		g.drawString(Total+"",w-6-String.valueOf(Total).length()*7,15);
		
		g.drawString("Limite",5,15+(h-25)/2);
		g.drawString(Limite+"",w-6-String.valueOf(Limite).length()*7,15+(h-25)/2);
		
		g.drawString("Pic",5,h-10);
		g.drawString(Pic+"",w-6-String.valueOf(Pic).length()*7,h-10);		
	}
	
	/**
	 * to refresh the datas of the Panel "Charge dediee".
	 * @param Total the memory used of the computer.
	 * @param Limite the limit of de memory of the computer.
	 * @param Pic the biggest value of the memory used.
	 */
	
	public void refresh(int Total,int Limite,int Pic){
		this.Total = Total;
		this.Limite = Limite;
		if(this.Pic < Pic)
		this.Pic = Pic;
	}
	
}

⌨️ 快捷键说明

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