<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

    該程序是很簡單 只是把我上一個程序可視化希望能給初學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;
     }
     
     
    }


    //服務器端

    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  
       {}  
    }  
    }



    //運行結果如下:
    不同時段 不同結果














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

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


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 日本免费电影一区二区| 国产精品亚洲自在线播放页码| 综合偷自拍亚洲乱中文字幕| 国产精品视频免费观看| 亚洲精品韩国美女在线| 四虎影视成人永久免费观看视频| 免费人成在线观看网站视频| 国产AV旡码专区亚洲AV苍井空| 91成年人免费视频| 亚洲一区二区三区高清不卡| 青青草国产免费久久久下载| www亚洲精品久久久乳| 少妇亚洲免费精品| 一级毛片免费毛片毛片| 国产精品亚洲成在人线| 亚洲成AV人片一区二区密柚| 免费黄网站在线看| 亚洲精品成人久久| 最近免费中文字幕大全| 男女超爽视频免费播放| 久久精品国产亚洲5555| 毛片无码免费无码播放| 亚洲一区精彩视频| 亚洲无码精品浪潮| 在线免费观看你懂的| 亚洲精品无码高潮喷水A片软| 国产成人免费片在线视频观看| 一级黄色片免费观看| 自怕偷自怕亚洲精品| 日本不卡高清中文字幕免费| 一级做受视频免费是看美女| 亚洲人成影院在线| 热99re久久免费视精品频软件| 一级一级一级毛片免费毛片| 久久久久亚洲精品美女| 四虎免费在线观看| 暖暖免费在线中文日本| 亚洲中文无码永久免| 亚洲乱码无码永久不卡在线| 国产精品美女午夜爽爽爽免费| 国产精品美女久久久免费|