我試圖在框架內製作一個簡單的按鈕,但按鈕圖標顯示不正確我的問題是爲什麼?我們爲什麼不能把 wingUtilities.invokeLater(new Runnable() {
S裏面的SwingDemo(),或public void actionPerformed(ActionEvent ae) 3.)哪些語句使edt線程? 請嘗試用簡單的詞語來解釋,否則更多的疑惑將會蔓延。事件調度線程
public void run() { new SwingDemo(); } });
import javax.swing.*;
import java.awt.event.*;
class SwingDemo implements ActionListener {
SwingDemo() {
JFrame jfrm = new JFrame("A Simple Swing Application");
jfrm.setSize(275, 100);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton jlab = new JButton(" Button ");
jfrm.add(jlab);
jfrm.setVisible(true);
}
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable() { //2
public void run() {
new SwingDemo();
}
});
}
public void actionPerformed(ActionEvent ae) {
//jlab.setText("You selected " + ae.getActionCommand());
//showStatus("You selected " + ae.getActionCommand());
}}
按鈕圖標_如何正確顯示? – Reimeus 2013-04-06 17:08:46