2008年9月18日 星期四
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.
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.
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日 星期三
2008年6月24日 星期二
2008年6月18日 星期三
export jar on jbuilder 2007
(1) when export:
choose src folder of each project
check:
Export all output folders for checked projects
add directory entries
2008年6月17日 星期二
2008年6月16日 星期一
jar
when creating jar, the package directory is created according to your command
Hence, if you want the class in test package , you must use
jar cvmf manifest.txt test
If test is in another directory , and you use
jar cvmf manifest.txt ../test
It will create test directory below .. directory, so it can not find test/*.class
訂閱:
文章 (Atom)