2011年5月24日 星期二

JTable specified row

changeSelection(int rowIndex,int columnIndex,boolean toggle,boolean extend) 
toggle: false, extend: false. Clear the previous selection and ensure the new cell is selected.  
toggle: false, extend: true. Extend the previous selection to include the specified cell. 
toggle: true, extend: false. If the specified cell is selected, deselect it. If it is not selected, select it. 
toggle: true, extend: true. Leave the selection state as it is, but move the anchor index to the specified location. 
reference:
javaworldjava 1.4.2 api

2011年5月18日 星期三

JFrame title and Windows taskbar

new Thread(){
    public void run(){
        String status="";
        int num=100000000;
        for(int i=0;i < num ;i++){
            DecimalFormat df=new DecimalFormat("##.##");
            status=df.format((double)i/num*100);//percentage
            if(i%1000==0){
                SwingUtilities.invokeLater(new Runnable(){
                     public void run(){
                        frame.setTitle(status+"%");
                    }
               });
           }
       }
   }
}.start();