如何命名应用程序并给它一个图标? [英] How to name application and give it an icon?

查看:350
本文介绍了如何命名应用程序并给它一个图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在eclipse工作,我已经做了一个没有名称和图标的应用程序。当我启动应用程序时,这是一个非常令人毛骨悚然的名字,显示在左上角(Mac)。这是一些事情。我想知道我该如何改变自己的名字。第二个问题是我如何改变图标。我可以在eclipse中这样做吗?

解决方案

优先的方法是创建一个 Mac OS应用程序包(和 bundler ),但是如果这似乎很多工作,您可以提供自定义属性,例如,您可以提供 Xdock:name

  -DXdock:name =应用程序名称

如果你不能这样做,你可以在应用程序运行时进行设置。

  public static void main(String [] args){
try {
// Sets菜单栏上的应用程序名称
System.setProperty(Xdock:name,Application Name);

//设置应用程序停靠图标...
应用程序应用程序= Application.getApplication();
application.setDockIconImage(ImageIO.read(TestDockIcon.class.getResource(/ Icon.png)));

//启动应用程序...
new TestDockIcon();
} catch(IOException exp){
exp.printStackTrace();
}
}


I'm working in eclipse and I have made an application without name and icon. When i start the application it's a really creepy name displaying in the upper left corner (Mac). It's some thing like. I wonder how I can change this to my own name. Second question is how i can change the icon. Can I do that in eclipse?

解决方案

The prefered method would be to create a Mac OS application bundle (and the bundler), but if this seems like to much work, you can supply custom properties to, for example, you could supply the Xdock:name property when running the application, for example...

-DXdock:name="Application Name"

If you can't do that, you can set it when your application runs, for example...

public static void main(String[] args) {
    try {
        // Sets the application name on the menu bar
        System.setProperty("Xdock:name", "Application Name");

        // Set the applications dock icon...
        Application application = Application.getApplication();            
        application.setDockIconImage(ImageIO.read(TestDockIcon.class.getResource("/Icon.png")));

        // Start the application...
        new TestDockIcon();
    } catch (IOException exp) {
        exp.printStackTrace();
    }
}

这篇关于如何命名应用程序并给它一个图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆