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();

2010年4月4日 星期日

NetBeans use GTK style

netbeans --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel

or

/etc/netbeans.conf

netbeans_default_options=" ... --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel"

2009年3月16日 星期一

GPG Key Error

Q:
W: GPG error: http://ppa.launchpad.net intrepid Release: 由於沒有公鑰,下列簽名無法進行驗證: NO_PUBKEY 60D11217247D1CFF

A:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 60D11217247D1CFF

2009年2月17日 星期二

Read HDFS File

FileSystem fs=FileSystem.get(new URI("hdfs://localhost:9000"),new Configuration());
FileStatus[] flist=fs.listStatus(new Path("input/"));

FSDataInputStream fsdatainput=fs.open(flist[0].getPath());
BufferedReader bfr=new BufferedReader(new InputStreamReader(fsdatainput));
while(bfr.ready())
{
System.out.println(bfr.readLine());
}

直接讀取比較省事!!

2009年2月10日 星期二

hadoop FileSystem

最近又要開始接觸hadoop了,為了把資料在程式裡直接上傳到HDFS裡,努力嘗試找了非常久的api。終於找到了FileSystem!暫時順利的將資料傳到HDFS。

FileSystem uptohdfs = FileSystem.get(new Path("hdfs://localhost:9000"),
new Configuration());
uptohdfs.copyFromLocalFile(Path src, Path dst) ;

上傳成功,要記得執行的使用者有寫入的權限!!

2008年10月22日 星期三

MATLAB ERROR!!

terminate called after throwing an instance of 'MathWorks::System::SimpleException'

This can be fixed by adding these two lines to /etc/rc.local

mkdir /dev/pts
mount -t devpts devpts /dev/pts