English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Assuming I have created two Java programs: Jav1.java and Jav24.java. What code should I include into Jav1.java's script [for a button] if I wish to load Jav24.java separately?

2007-02-27 07:58:03 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

//swing JButton, could just as easily be an AWT Button
JButton launch = new JButton("Launch");
String[] cmds = {"java.exe", "Java24"};

launch.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
Runtime currentRT = Runtime.getRuntime();
currentRT.exec(cmds);//launches a new Java process
}

//then add launch button to your GUI

2007-03-02 03:04:13 · answer #1 · answered by vincentgl 5 · 0 0

You want to import the java "awt", the java "swing' or both. There are many examples on the web for building a GUI the would allow you to load a java class by pushing a GUI button.

2007-02-27 08:10:24 · answer #2 · answered by Ernie 4 · 0 0

As CurrentPrice is asserted as an Integer, you will not be able to transform right into a decimal extensive sort. in case you prefer declare it as a Double. Double CurrentPrice = 20.0; CurrentPrice= CurrentPrice/one hundred.0; in case you prefer to transform Int right into a Double; int CurrentPrice= 20; Double.parseDouble(CurrentPrice); CurrentPrice= CurrentPrice/one hundred.0;

2016-10-16 21:50:14 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers