(
① TestFrame類
TestFrame是Java運行主程序
import javax
import java
import java
public class TestFrame extends JFrame
{
//GUI所需組件
public JPanel testPanel = null;
public JButton testButton = null;
public JFrame testFrame = null;
public TestFrame()
{
//設置GUI為windows風格
try
{
UIManager
}
catch (Exception ex)
{
System
}
testFrame = this;
// 初始化GUI
Dimension dimensions = Toolkit
setSize(dimensions
setLocation(dimensions
dimensions
testPanel = new JPanel();
testButton = new JButton(
testPanel
getContentPane()
//增加按鈕testButton事件監聽器
testButton
public void actionPerformed(ActionEvent e) {
TestThread testThread = new TestThread();//新生成一個處理事務線程
testThread
(new ThreadDiag(testFrame
}
});
//增加testFrame事件監聽器
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e) {
System
}
});
}
public static void main(String[] args)
{
//主程序
TestFrame testFrame
testFrame
testFrame
}
}
[
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27676.html