| | |
executing a .java file from another .java file
![]() |
WHAT i want to happen is, when i click the CALCULATOR menu item, my separate Calculator.java will run on the MenuShortCut JFrame.
AGAIN, i want the separate .java file to appear on THE SAME JFrame of MenuShortCut class.
here's what i've got
can i do that using this?
if yes, codes do i need to add in order to get it working? (i get unreported exception error)
thanks.
AGAIN, i want the separate .java file to appear on THE SAME JFrame of MenuShortCut class.
here's what i've got
java Syntax (Toggle Plain Text)
import javax.swing.*; import java.awt.event.*; public class MenuShortcut extends JFrame implements ActionListener{ JMenuBar menuBar; JMenu files,help; JMenuItem cs[],calc,game,exit,about; public MenuShortcut() { super("Team Shrek"); menuBar = new JMenuBar(); files = new JMenu("File"); help = new JMenu("Help"); cs = new JMenuItem[5]; calc = new JMenuItem("Calculator"); game = new JMenuItem("Word Game"); exit = new JMenuItem("Exit"); about = new JMenuItem("About"); for(int i=0;i<5;i++) { cs[i] = new JMenuItem("CaseStudy "+(i+1)); cs[i].addActionListener(this); files.add(cs[i]); } files.addSeparator(); files.add(calc); files.add(game); files.addSeparator(); files.add(exit); help.add(about); menuBar.add(files); menuBar.add(help); setJMenuBar(menuBar); setSize(250,200); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { new MenuShortcut(); } public void actionPerformed(ActionEvent e) { //some events here } }
can i do that using this?
java Syntax (Toggle Plain Text)
Runtime.getRuntime().exec( "java programname.java" );
if yes, codes do i need to add in order to get it working? (i get unreported exception error)
thanks.
a joke.
![]() |
Similar Threads
- How to run a *.exe file in Java (Java)
- Help to read .pst file from java (Java)
- how to read CSV file in java (Java)
- How to make .exe file for my java prg (Java)
- parsing error (XML file-java-schema) (Java)
- line up JTextField GUI java & write to file (Java)
Other Threads in the Java Forum
- Previous Thread: Socket passing double type value from c++ to java
- Next Thread: Logical Error - Calculator - Memory
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows





