| | |
executing a .java file from another .java file
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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 |
Tag cloud for Java
affinetransform android api append apple applet application arguments array arrays automation bi binary bluetooth businessintelligence busy_handler(null) chat class classes client code component database draw eclipse encryption equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop main map method methods mobile netbeans newbie number open-source oracle oriented panel print problem program programming project qt recursion reference replaysolutions repositories return robot scanner screen scrollbar se server set singleton size sms socket sort sql string swing test threads time tree utility windows xor





