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() {
setTitle("GetSum!");
setSize(300,200);
JTabbedPane jtp = new JTabbedPane();
getContentPane().add(jtp);
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!");
jp1.add(label1);
jp2.add(label2);
jp3.add(label3);
jtp.addTab("Welcome!", jp1);
jtp.addTab("Web Browsers", jp2);
jtp.addTab("Games", jp3);
jp2.add(b1);
jp3.add(b2);
jp2.add(b3);
jp3.add(b4);
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();
tp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tp.setVisible(true);
}
}
Thanks, I hope you can help : - /