?? frameproductstoryinformationshow.java
字號:
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(); 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); }//畫圖過程,重寫窗體的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.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 + -