一个非常简单的问题。我试图从Eclipse运行一个非常简单的演示,创建并显示一个窗口框架,但什么也没发生。没有错误,没有窗口,代码已经运行完成。
我添加了断点,并确保代码按预期运行。这段代码直接来自于Java教程(FrameDemo),我只是将包重命名以适应我放置它的位置(此包中的其他代码都运行良好):
package ui;
import java.awt.*;
import javax.swing.*;
/* FrameDemo.java requires no other files. */
public class FrameDemo {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel emptyLabel = new JLabel("");
emptyLabel.setPreferredSize(new Dimension(175, 100));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
我的安装配置(Kepler SR2):
- eclipse.buildId=4.3.2.M20140221-1700
- java.version=1.8.0_05
- java.vendor=Oracle Corporation
- BootLoader常量:OS=macosx,ARCH=x86_64,WS=cocoa,NL=en_US
- 框架参数:-product org.eclipse.epp.package.java.product -keyring /Users/steve/.eclipse_keyring -showlocation
- 命令行参数:-os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.java.product -keyring /Users/steve/.eclipse_keyring -showlocation
我还检查了Configuration->错误日志; 仍然没有任何错误。我尝试过其他类似的演示文稿,结果相同。
如果有帮助,将不胜感激,因为我已经被卡在这个问题上一天了。