📄 frameproductstoryinformationshow.java~2~
字号:
package Manager;import javax.swing.*;import java.awt.*;import com.borland.jbcl.layout.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class FrameProductStoryInformationShow extends JFrame { //用于接收传过来的值 float[] size={0,0,0,0,0,0,0,0,0}; XYLayout xYLayout1 = new XYLayout(); XYLayout xYLayout2 = new XYLayout(); XYLayout xYLayout3 = new XYLayout(); JPanel jPanelShow = new JPanel(); XYLayout xYLayout4 = new XYLayout(); JLabel jLabel1 = new JLabel(); public FrameProductStoryInformationShow() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //重写的构造函数,用于传递数组 public FrameProductStoryInformationShow( float[] msize ) { size=msize; try { jbInit(); } catch(Exception e) { e.printStackTrace(); }} public static void main(String[] args) { FrameProductStoryInformationShow frameProductStoryInformationShow = 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("Dialog", 0, 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); }//画图 public void paint(Graphics g){ g=jPanelShow.getGraphics();//得到jPanelShow的Graphics对象 float intMax=0; float MAXlength =600; for (int i=0;i<=8;i++) { if(intMax<size[i]) {intMax=size[i]; } }//开始绘图 g.setColor(Color.red ) ; 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,40); g.fillRect(10,50,(int)(size[1] * MAXlength/ intMax ),10); g.setColor(Color.blue ) ; g.drawString("38 号 数量:"+(int)size[2],10,70); g.fillRect(10,80,(int)(size[2] * MAXlength/ intMax ),10); g.setColor(Color.yellow ) ; g.drawString("39 号 数量:"+(int)size[3],10,100); g.fillRect(10,110,(int)(size[3] * MAXlength/ intMax ) ,10); g.setColor(Color.white ) ; g.drawString("40 号 数量:"+(int)size[4],10,130); g.fillRect(10,140,(int)(size[4] * MAXlength/ intMax),10); g.setColor(Color.green ) ; g.drawString("41 号 数量:"+(int)size[5],10,160); g.fillRect(10,170,(int)(size[5]* MAXlength / intMax ),10); g.setColor(Color.cyan ) ; g.drawString("42 号 数量:"+(int)size[6],10,190); g.fillRect(10,200,(int)(size[6] * MAXlength/ intMax ),10); g.setColor(Color.darkGray) ; g.drawString("43 号 数量:"+(int)size[7],10,220); g.fillRect(10,230,(int)(size[7]* MAXlength / intMax ),10); g.setColor(Color.yellow ) ; g.drawString("44 号 数量:"+(int)size[8],10,250); g.fillRect(10,260,(int)(size[8] * MAXlength/ intMax ),10); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -