简体   繁体   English

Eclipse中的Java Swing JFontChooser“未找到主要”

[英]Java Swing JFontChooser “main not found” in eclipse

I'm a newbie to eclipse. 我是个新手。 (I've done many java programs through command line) I'm doing a Java Swing project and wanted to implement a Font dialog box. (我已经通过命令行完成了许多Java程序)我正在执行Java Swing项目,并希望实现“字体”对话框。

I Found that JFontChooser was a nice implementation and it was open source. 我发现JFontChooser是一个不错的实现,并且是开源的。 I downloaded the source. 我下载了源代码。 But when I import it in eclipse it had problems (like "package name did not match",etc.) I rectified them, by matching with the file structure. 但是,当我将其导入eclipse时,出现了问题(例如“包名称不匹配”等),我通过与文件结构匹配来纠正了它们。 I referred to this forum post 我提到了这个论坛帖子

I got rid of all the errors but still when I run, it gives a error box saying Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.say.swing Even after a google search I cant find the solution to the problem. 我摆脱了所有错误,但是仍然可以在运行时显示一个错误框,指出线程“ main”中的异常java.lang.SecurityException:禁止的软件包名称:java.say.swing即使在Google搜索后,我也找不到解决方案解决问题。

Can someone give me the solution to rectify this problem? 有人可以给我解决方案以纠正此问题吗? If you can please download the source. 如果可以,请下载源代码。 :) :)

Info:I created a new package in eclipse with other names like: java.say.sting AND say.sting. 信息:我在eclipse中创建了一个新包,并带有其他名称,例如:java.say.sting和say.sting。 But it gives me the same error or Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name say.sting.JFontChooserMessages, locale en_IN 但是它在线程“主”中给了我相同的错误或异常java.util.MissingResourceException:找不到基本名称为say.sting.JFontChooserMessages的包,语言环境为en_IN

  1. Typically you would not import the source for a 3rd party library, you would just add the .jar file to your classpath. 通常,您不会导入第三方库的源代码,只需将.jar文件添加到类路径中。 That would resolve the package name not matching, I'm guessing. 我猜这将解决软件包名称不匹配的问题。

  2. "Selection does not contain main type" means just that--you're trying to launch a class which has no main method. “选择不包含主类型”意味着-您正在尝试启动没有main方法的类。 Libraries do not typically include main methods. 图书馆通常不包括主要方法。

Got the solution: 得到了解决方案:

It needed a java properties file. 它需要一个Java属性文件。 Wonder why people @ SO couldn't find such a simple thing. 想知道为什么人们@ SO找不到这么简单的东西。 A friend of mine did it for me. 我的一个朋友为我做了。 AND I feel short of words to thank him. 而且我无话可说要感谢他。

The propertiers contents 属性内容

    Version=1.0.5 
# #dialog title 
SelectFont=Select Font 
OK=OK 
Cancel=Cancel 
# # labels 
FontName=Font Name 
FontStyle=Style
FontSize=Size 
Sample=Sample 
# # sample text
SampleString=Jaison 
# # font style 
Plain=Plain Bold=Bold Italic=Italic BoldItalic=Bold Italic

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM