<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++博客   博問  
     
    主站蜘蛛池模板: 成人免费网站久久久| 色老头综合免费视频| xxxxxx日本处大片免费看| 中文在线免费不卡视频| 黄色成人免费网站| 亚洲国产精品一区二区第一页免 | 久久亚洲AV无码精品色午夜麻豆 | 久久亚洲国产中v天仙www| 亚洲二区在线视频| 国产精品免费αv视频| 两个人的视频高清在线观看免费| 亚洲国产成人久久一区WWW| 在线精品自拍亚洲第一区| 99久久免费中文字幕精品| 免费a级毛片视频| 亚洲三级视频在线观看| 国精产品一区一区三区免费视频| 麻豆成人精品国产免费| 亚洲av日韩av高潮潮喷无码| 青草青草视频2免费观看| 国产成人免费网站| 亚洲日本在线看片| 最好免费观看高清在线| 亚洲视频在线免费观看| 国产男女爽爽爽爽爽免费视频| 亚洲免费视频播放| 国产免费AV片无码永久免费| 亚洲人成网男女大片在线播放| 日韩av无码久久精品免费| 亚洲精品电影在线| 中文字幕免费在线| 久久亚洲国产精品成人AV秋霞| 美女视频黄免费亚洲| 亚洲福利秒拍一区二区| 免费看美女让人桶尿口| 亚洲黄片手机免费观看| 久久精品国产亚洲av水果派| 无码免费一区二区三区免费播放| 亚洲成av人片天堂网| 中国在线观看免费高清完整版| 亚洲a无码综合a国产av中文|