在eclipse中使用windowbuilder进行Java应用程序的I / O.

问题描述 投票:0回答:1

我之前从未使用过java windowbuilder,但是我试图用我的程序测试它,它在集合上执行操作。这是Gradle项目。我在默认包中编写了所有类(我知道在完成时我们气馁)。程序读取集合上的一系列操作,解析它并打印结果,并在用户输入新行时继续这样做。我正在尝试使用windowbuilder为这个程序创建一个简单的GUI但我无法弄清楚如何在windowbuilder类中运行主类并使其从jtextfield获取输入并打印输出。

我的主要看起来像这样:

public static void main(String[] argv) { 
        new Main().start(); 
    } 

    private void start() { 
        hmap  = new HashMap<IdentifierInterface, SetInterface<BigInteger>>();
        Scanner in = new Scanner(System.in);  
        // While there is input, read line and parse it. 
        while (in.hasNextLine()) { 
            try { 
                String statement = in.nextLine(); 
                if (statement.trim().isEmpty()) { 
                    System.out.println("error, no statement"); 
                } else { 
                    Scanner statementScanner = new Scanner(statement); 
                    readStatement(statementScanner); 
                } 
            } catch (APException e) { 
                System.out.printf("%s\n", e.getMessage()); 
            } 
        }
    } 

我用按钮和文本字段创建了一个新的windowbuilder类,但是我仍然坚持如何在windowbuilder中运行我的main。非常感谢您的帮助。提前致谢。

java eclipse windowbuilder
1个回答
0
投票

Eclipse RCP应用程序是OSGi插件;他们没有main()方法。

相反,您的Main类应如下所示:

package com.myplugin;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Main implements BundleActivator {
    @Override
    public void start(BundleContext bundleContext) throws Exception {
        // Copy your start logic here
    }
}

然后编辑META-INF / MANIFEST.MF文件并设置为例

Bundle-Activator: com.myplugin.Main

这使您的Main类成为插件的激活器:start()将在加载时调用。

© www.soinside.com 2019 - 2024. All rights reserved.