2008年9月18日 星期四

2008年8月5日 星期二

eclipse

set classpath:
.classpath

2008年7月23日 星期三

event dispatch thread

all access to Swingcomponents needs to be done from a single thread—the event-dispatch thread

how to know whether you are in event dispatch thread
method1:
EventQueue.isDispatchThread()

method2:
SwingUtilities.isEventDispatchThread()

how to give tasks to event diskpatch thread:
add runnable object to event queue
method1:
EventQueue.invokeLater(Runnable runnable)
don't care when the task finishes

method2:
EventQueue.invokeAndWait(Runnable runnable)
wait until task done

ex:
Runner runner = new Runnable(){
public void run(){
JFrame frame=new JFrame();
frame.setVisible(true);
}
};
EventQueue.

JTable

JTable's  mothod
getModel:
Returns the TableModel that provides the data displayed by this JTable.

modify table's behavior:
define a class that extends DefaultTableModel

DefaultTableModel's method
void addRow(Object[] rowData)

2008年7月18日 星期五

JOptionPane

show message box

showConfirmDialog
   Asks a confirming question, like yes/no/cancel.
showInputDialog
  Prompt for some input.
showMessageDialog
  Tell the user about something that has happened.
showOptionDialog
  The Grand Unification of the above three.

2008年6月29日 星期日

ant

like makefile

use xml

create a file called build.xml.  Then run ant.  Then the project is compiled 
( ant -verbose will print more information)

the top level element is project, its default attribute decides which target to do
ex:
<project name="Test"  default="compile">

the target's depends property decides what targets must be done before it
ex:
<target name="compile"  depends="init>

how to run ant:
1. ant  
   this will execute default target
2. ant  targetName

show information about build.xml
ant -projecthelp
show the targets with their description
( the description is described by description property of each target)

some useful tasks:
1. javac  srcdir="src", destdir="bin"
compile java codes

2.  <echo>hello</echo>
print message when running ant 

3, <mkdir  dir="test/bin"/>

4. <jar  destfile="dist/test.jar"  basedir="bin" />

5. <delete dir="bin" />

6. <java classname="Test.Main"  classpath="bin">
    <arg value="peter"/>
    <arg value="andy"/>
   <arg file="."/>
   </java>

2008年6月25日 星期三

jh.jar, jmf.jar

javax.help  package is in jh.jar

javax.media package is in jmf.jar