使用Eclipse创建一个简单的应用程序启动器

时间:2014-11-21 05:00:00

标签: java eclipse swing deployment

我是编程新手,需要帮助或作弊。我正在尝试使用eclipse创建一个Windows应用程序,它只是从顶部工具栏的下拉菜单中启动其他应用程序。有点像Hirens引导cd菜单看起来和工作,但我自己的应用程序。它们也需要从便携式USB上运行。提前谢谢。

这是我到目前为止所做的。

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;

public class Launcher {

    private JFrame frame;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Launcher window = new Launcher();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public Launcher() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JMenuBar menuBar = new JMenuBar();
        frame.setJMenuBar(menuBar);

        JMenu mnVirusRemoval = new JMenu("Virus Removal");
        menuBar.add(mnVirusRemoval);

        JButton btnFirefox = new JButton("Opera");
        btnFirefox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                @SuppressWarnings("unused")
                Process process = null;

                try {
                    process = Runtime.getRuntime().exec("IDK WHAT GOES HERE");
                } 

                catch (IOException e) 

                {
                    e.printStackTrace();
                }
            }
        });
        mnVirusRemoval.add(btnFirefox);
    }

}

0 个答案:

没有答案
相关问题