<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    洛神賦

    子虛烏有

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      7 Posts :: 10 Stories :: 0 Comments :: 0 Trackbacks

    該程序是很簡單 只是把我上一個程序可視化希望能給初學(xué)java的人提供幫助!!!

    //stock

    package StockUI;

    public class Stock {

     private int id;      // 
     private String name;  //
     private int price;  //
     private int flag;   //
     
     
     public int getId() {
      return id;
     }
     public void setId(int id) {
      this.id = id;
     }
     public String getName() {
      return name;
     }
     public void setName(String name) {
      this.name = name;
     }
     public int getPrice() {
      return price;
     }
     public void setPrice(int price) {
      this.price = price;
     }
     public int getFlag() {
      return flag;
     }
     public void setFlag(int flag) {
      this.flag = flag;
     }
     
     
    }


    //服務(wù)器端

    package StockUI;

    import java.util.Random;


    public class StockServer {

     
     public static void main(String[] args){
      
      
      Stock sk[] = getStock();
      for(int i=0;i<sk.length;i++){
       if(sk[i] != null){
        System.out.println("name = " + sk[i].getPrice());
        
       }
      }
     }
     
     
     public static Stock[] getStock(){
      
      
      Stock stock[] = new Stock[3];
     //##################################################### 
      Stock sk = new Stock();
      sk.setId(1);
      sk.setName("ibm");
      Random rd = new Random();
      sk.setPrice(rd.nextInt(100));
      sk.setFlag(1);
      stock[0] = sk;
     //#######################################################
      Stock sk1 = new Stock();
      sk1.setId(2);
      sk1.setName("sun");  
      sk1.setPrice(rd.nextInt(100));
      sk1.setFlag(1);
      stock[1] = sk1;
     //###################################################### 
      Stock sk2 = new Stock();
      sk2.setId(3);
      sk2.setName("oracle");  
      sk2.setPrice(rd.nextInt(100));
      sk2.setFlag(1);
      stock[2] = sk2;
      
      
      
      return stock;
      
     }
     
    }




    package StockUI;
     
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.TableEditor;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Menu;
    import org.eclipse.swt.widgets.MenuItem;
    import org.eclipse.swt.widgets.MessageBox;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Table;
    import org.eclipse.swt.widgets.TableColumn;
    import org.eclipse.swt.widgets.TableItem;

     

    public class StockUI {
     
    private TableEditor editor = null;  
    private Table table = null; 

    public static void main(String[] args) {  
       new StockUI();  
    }  
    private StockUI() {  
       Display display = new Display();  
       Shell shell = new Shell(display);  
       shell.setLayout(new FillLayout());  
       shell.setText("大智慧股票模擬系統(tǒng)");  
       createTable(shell,display);  
       shell.pack();       //窗口變大
       shell.open();  
       while (!shell.isDisposed()) {  
        if (!display.readAndDispatch())  
         display.sleep();  
       }  
       display.dispose();  
    }  
    /** 
    * 創(chuàng)建表格 
    *  
    * @param shell 
    */ 
    private void createTable(final Shell shell,final Display display) {  
       table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);  
       editor = new TableEditor(table);  
       editor.horizontalAlignment = SWT.LEFT;  
       editor.grabHorizontal = true;  
       table.setHeaderVisible(true);  
       table.setLinesVisible(true);  
       TableColumn col1 = new TableColumn(table, SWT.LEFT);  
       col1.setText("股票代碼");  
       col1.setWidth(100);  
       TableColumn col2 = new TableColumn(table, SWT.LEFT);  
       col2.setText("公司名");  
       col2.setWidth(100);  
       TableColumn col5 = new TableColumn(table, SWT.LEFT);  
       col5.setText("現(xiàn)價");  
       col5.setWidth(100);  
       TableColumn col3 = new TableColumn(table, SWT.LEFT);  
       col3.setText("漲幅");  
       col3.setWidth(100);  
       TableColumn col4 = new TableColumn(table, SWT.LEFT);  
       col4.setText("換手率");  
       col4.setWidth(100);  
       /** 
       * 添加表格數(shù)據(jù) 
       */ 
     
      
       Stock[] sk = StockServer.getStock();
       final TableItem[] itemArr = new TableItem[sk.length];
       for(int i=0;i<itemArr.length;i++){
       itemArr[i] = new TableItem(table, SWT.LEFT);
       }
       
     final int time=1000;  
        Runnable showTime = new Runnable(){          
              public void run(){  
               Stock[] sk = StockServer.getStock();
               for(int i=0;i<itemArr.length;i++){
                itemArr[i].setText(new String[] { String.valueOf(sk[i].getId()), String.valueOf(sk[i].getName()), String.valueOf(sk[i].getPrice())
                   });
               }   
                  display.timerExec(time, this);  
              }  
        };                  
     display.timerExec(time,showTime);//你的swt程序的display
      
      
       // 刪除菜單  
       Menu menu1 = new Menu(shell, SWT.POP_UP);  
       table.setMenu(menu1);  
       MenuItem menuitem1 = new MenuItem(menu1, SWT.PUSH);  
       menuitem1.setText("刪除");  
       menuitem1.addListener(SWT.Selection, new Listener() {  
        @Override 
        public void handleEvent(Event event) {  
         MessageBox mbox = new MessageBox(shell, SWT.DIALOG_TRIM|SWT.ICON_INFORMATION);  
         mbox.setText("刪除成功");  
         mbox.setMessage("刪除了" + table.getSelectionCount() + "條記錄");  
         table.remove(table.getSelectionIndices());  
         mbox.open();  
        }  
       });  
       // 修改table  
       {}  
    }  
    }



    //運行結(jié)果如下:
    不同時段 不同結(jié)果














    posted on 2010-11-03 20:40 洛神賦 閱讀(433) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 一本色道久久88—综合亚洲精品 | 午夜男人一级毛片免费 | 久久亚洲国产精品五月天| 国产亚洲综合视频| 在线观看91精品国产不卡免费| 在线综合亚洲欧洲综合网站 | 国产一级淫片a免费播放口之| 亚洲sm另类一区二区三区| 成全高清视频免费观看| 亚洲七久久之综合七久久| 四虎成人免费大片在线| 亚洲一区二区三区丝袜| 日本高清免费不卡在线| 国产亚洲男人的天堂在线观看| 亚洲AV伊人久久青青草原| jizz在线免费观看| 亚洲成a人片77777老司机| 中文字幕免费在线| 亚洲xxxx视频| 亚洲av无码乱码在线观看野外 | 国产亚洲综合视频| 亚洲综合日韩久久成人AV| 国偷自产一区二区免费视频| 中文字幕亚洲色图| 国内大片在线免费看| 一本大道一卡二大卡三卡免费| 亚洲VA中文字幕无码毛片| 4虎永免费最新永久免费地址| 亚洲国产欧美一区二区三区| 国产a v无码专区亚洲av| 亚欧免费无码aⅴ在线观看| 亚洲一区二区三区不卡在线播放| 成人黄软件网18免费下载成人黄18免费视频 | 日韩在线天堂免费观看 | 久久国产乱子免费精品| 亚洲 日韩 色 图网站| 久久精品国产亚洲精品| 久久天天躁狠狠躁夜夜免费观看| 免费人成动漫在线播放r18| 精品亚洲aⅴ在线观看| 亚洲国产精品成人|