Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Executing a program on my computer with an ActionListener?

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Default Executing a program on my computer with an ActionListener?

    HI, Ive only been learning Java for about 2 months and ive run into this problem while making a program. I have plenty of knowledge on ActionListeners but ive no idea how to program my button to execute a program like firefox, or a game on my hard disk. Running such programs is the whole point of my program so its kind of urgent....
    Here is what i have so far.....

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class newGUI extends JFrame {

    public newGUI() {


    JTabbedPane jtp = new JTabbedPane();

    JPanel jp1 = new JPanel();
    JPanel jp2 = new JPanel();
    JPanel jp3 = new JPanel();
    JButton b1 = new JButton("Firefox");
    JButton b2 = new JButton("Minecraft");
    JButton b3 = new JButton("Chrome");
    JButton b4 = new JButton("Dead Space");

    JLabel label1 = new JLabel();
    label1.setText("Welcome To GetSum! Please select a menu:");
    JLabel label2 = new JLabel();
    label2.setText("The Website Menu!!!)");
    JLabel label3 = new JLabel();
    label3.setText("The Games Menu!");
    jtp.addTab("Welcome!", jp1);
    jtp.addTab("Web Browsers", jp2);
    jtp.addTab("Games", jp3);
    b1.addActionListener(new Action());

    static class Action implements ActionListener{

    public void actionPerformed (ActionEvent e){
    What should i put here to execute Firefox?


    public static void main(String[] args) {

    newGUI tp = new newGUI();


    Thanks, I hope you can help : - /

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Executing a program on my computer with an ActionListener?

    Runtime.exec()? The API is your friend.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 3
    Last Post: March 1st, 2011, 02:18 PM
  2. issue in executing Stored Proc
    By Bhawesh Kurmi in forum JDBC & Databases
    Replies: 1
    Last Post: December 8th, 2010, 10:05 AM
  3. Executing Oracle Procedure
    By java_mein in forum JDBC & Databases
    Replies: 0
    Last Post: May 14th, 2010, 02:41 PM
  4. Help Executing C Program From Java! (Ubuntu)
    By penguinGirl in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 18th, 2010, 01:47 PM
  5. [SOLVED] Detecting whether the piece of code is executing?
    By vivek1982 in forum Web Frameworks
    Replies: 4
    Last Post: March 27th, 2009, 06:17 AM

Tags for this Thread