热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

从Eclipse运行时不出现JavaJFrame窗口-JavaJFrameWindownotappearingwhenrunfromEclipse

Averysimpleproblem.ItrytorunaverysimpledemotocreatedanddisplayaWindowFramefromEc

A very simple problem. I try to run a very simple demo to created and display a Window Frame from Eclipse, and nothing happens. No errors, no window, the code runs to completion.

一个非常简单的问题。我尝试运行一个非常简单的演示来创建和显示Eclipse的Window Frame,但没有任何反应。没有错误,没有窗口,代码运行完成。

I added breakpoints and made sure the code runs as expected. The code is straight from Java tutorials (FrameDemo), I just renamed the package to fit where I placed it (other code from this package runs fine):

我添加了断点并确保代码按预期运行。代码直接来自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();
            }
        });
    }
}

My setup (Kepler SR2):

我的设置(开普勒SR2):

  • eclipse.buildId=4.3.2.M20140221-1700
  • eclipse.buildId = 4.3.2.M20140221-1700
  • java.version=1.8.0_05
  • java.version = 1.8.0_05
  • java.vendor=Oracle Corporation
  • java.vendor = Oracle Corporation
  • BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
  • BootLoader常量:OS = macosx,ARCH = x86_64,WS = cocoa,NL = en_US
  • Framework arguments: -product org.eclipse.epp.package.java.product -keyring /Users/steve/.eclipse_keyring -showlocation
  • 框架参数:-product org.eclipse.epp.package.java.product -keyring /Users/steve/.eclipse_keyring -showlocation
  • Command-line arguments: -os macosx -ws cocoa -arch x86_64 -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

I also checked Configuration -> error logs; still nothing, no errors. I tried other similar demos, same results.

我还检查了配置 - >错误日志;仍然没有,没有错误。我尝试了其他类似的演示,结果相同。

Any help would be appreciated as I have been stuck on this for over a day.

任何帮助将不胜感激,因为我已被困在这一天超过一天。

1 个解决方案

#1


9  

It turns out I had a library problem. I had had imported all the jars in the .lib directory from jfreechart. In reality only two were needed and some unnecessary ones were labeled swt and experimental. Once I removed all the ones that were not needed, did a clean, and rebuilt, everything worked fine.

事实证明我有一个库问题。我从jfreechart导入了.lib目录中的所有jar。实际上只需要两个,一些不必要的标记为swt和experimental。一旦我删除了所有不需要的东西,干净,重建,一切都运行正常。

Oddly, changing the order of the jfreechart library (which included the conflicting jars) to the bottom did not help, the extra jars had to be removed.

奇怪的是,将jfreechart库(包括冲突的罐子)的顺序更改为底部没有帮助,必须删除额外的罐子。

Not a jfreechart issue, obviously my own library import issue. If you run into this I suggest you try to remove some of the libraries that may be conflicting, then clean, build, and run again.

不是jfreechart问题,显然是我自己的库导入问题。如果遇到这种情况,我建议您尝试删除一些可能存在冲突的库,然后再清理,构建和运行。

Thanks to Hovercraft Full Of Eels and everyone else who responded for helping me out.

感谢Hovercraft Full Of Eels和其他所有回应帮助我的人。


推荐阅读
author-avatar
手机用户2502895961
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有