📄 frameproductstoryinformationshow.java
字号:
package Manager;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import com.borland.jbcl.layout.*;
public class FrameProductStoryInformationShow extends JFrame {
/**
* <p>Title:库存信息图形化显示 </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2008</p>
* <p>Company:南华大学计算机系 </p>
* @author 王云飞
* @version 1.0
*/
private static final long serialVersionUID = 1L;
//用于接收传过来的值
float[] size={0,0,0,0,0,0,0,0,0};
XYLayout xYLayout1 = new XYLayout();
JPanel jPanelShow = new JPanel();
XYLayout xYLayout4 = new XYLayout();
//JLabel jLabel1 = new JLabel();
ImageIcon jicon = new ImageIcon("images" + File.separator+"湖在天上.JPG");
JLabel jLabel1 = new JLabel(jicon, JLabel.CENTER);
public FrameProductStoryInformationShow() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//重写的构造函数,用于传递数组
public FrameProductStoryInformationShow( float[] msize ) {
size=msize;
//this.setSize(new Dimension(680, 380));
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new FrameProductStoryInformationShow();
}
private void jbInit() throws Exception {
this.setTitle("库存分析");
this.getContentPane().setLayout(xYLayout1);
xYLayout1.setWidth(682);
xYLayout1.setHeight(392);
jPanelShow.setBorder(BorderFactory.createLineBorder(Color.black));
jPanelShow.setLayout(xYLayout4);
jLabel1.setFont(new java.awt.Font("宋体", Font.ITALIC+Font.BOLD, 16));
jLabel1.setText("图形化分析结果如下:");
this.getContentPane().add(jPanelShow,new XYConstraints(23, 46, 633, 326));
this.getContentPane().add(jLabel1, new XYConstraints(47, 13, 333, 29));
this.setSize(650,400);
}
//画图过程,重写窗体的paint过程
public void paint(Graphics g){
//得到jPanelShow的Graphics对象
g=jPanelShow.getGraphics();
float intMax=0;
float MAXlength =600;
//计算最长行长,以它为基数计算其他行长
for (int i=0;i<=8;i++)
{
if(intMax<size[i])
{intMax=size[i];
}
}
//开始绘图
g.setColor(Color.blue ) ;
g.drawString("36 号 数量:"+(int)size[0],10,10);
g.fillRect(10,20,(int)(size[0] * MAXlength/ intMax ),10);
g.setColor(Color.black ) ;
g.drawString("37 号 数量:"+(int)size[1],10,45);
g.fillRect(10,55,(int)(size[1] * MAXlength/ intMax ),10);
g.setColor(Color.blue ) ;
g.drawString("38 号 数量:"+(int)size[2],10,80);
g.fillRect(10,90,(int)(size[2] * MAXlength/ intMax ),10);
g.setColor(Color.cyan ) ;
g.drawString("39 号 数量:"+(int)size[3],10,115);
g.fillRect(10,125,(int)(size[3] * MAXlength/ intMax ) ,10);
g.setColor(Color.black) ;
g.drawString("40 号 数量:"+(int)size[4],10,150);
g.fillRect(10,160,(int)(size[4] * MAXlength/ intMax),10);
g.setColor(Color.green ) ;
g.drawString("41 号 数量:"+(int)size[5],10,185);
g.fillRect(10,195,(int)(size[5]* MAXlength / intMax ),10);
g.setColor(Color.cyan ) ;
g.drawString("42 号 数量:"+(int)size[6],10,220);
g.fillRect(10,230,(int)(size[6] * MAXlength/ intMax ),10);
g.setColor(Color.darkGray) ;
g.drawString("43 号 数量:"+(int)size[7],10,255);
g.fillRect(10,265,(int)(size[7]* MAXlength / intMax ),10);
g.setColor(Color.green ) ;
g.drawString("44 号 数量:"+(int)size[8],10,290);
g.fillRect(10,300,(int)(size[8] * MAXlength/ intMax ),10);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -