Results 1 to 6 of 6
- 01-21-2009, 05:10 AM #1
Help! problem with program (using JFrame)
Hi!
I am trying to make a simple program that will run an excutable after i click "Play" in my program. (In my case i am trying to open WarCraft III, but you can change it to like Word, or something that you have) I am using JFrameBuilder to make the frame, then JCreator to edit it. (Because i have only taken one semester of java at school, and that's all the programing i know.)
My problem is this error that i can not solve (line 32), I attached a picture of the error, and the code itself.
Thanks!Last edited by linux1man; 01-21-2009 at 05:17 AM.
-- Ubuntu 8.04 (Linux) O.P.S. 512mb RAM
-- 2.66 Ghz Pentium Geforce NVidia 440 64mb
- 01-21-2009, 05:59 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Couldn't find the attachment here. Most probably you cannot do that. Better to copy-pate the error message here.
- 01-21-2009, 10:35 AM #3
i coudn't understand what problem u had.
- 01-21-2009, 08:40 PM #4
ok, this is the code
Java Code:/****************************************************************/ /* Run */ /* */ /****************************************************************/ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class Run extends JFrame { private JButton jButton1; private JPanel contentPane; public Run()throws Exception { super(); try { initializeComponent(); } catch (Exception ex) { System.out.println("Failed loading L&F: "); System.out.println(ex); } this.setVisible(true); } private void initializeComponent()throws Exception { jButton1 = new JButton(); contentPane = (JPanel)this.getContentPane(); jButton1.setText("Play!"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.setLayout(null); addComponent(contentPane, jButton1, 37,27,83,28); this.setTitle("Run "); this.setLocation(new Point(254, 274)); this.setSize(new Dimension(165, 119)); this.setResizable(false); } private void addComponent(Container container,Component c,int x,int y,int width,int height) { c.setBounds(x,y,width,height); container.add(c); } private void jButton1_actionPerformed(ActionEvent e) { System.out.println("\njButton1_actionPerformed(ActionEvent e) called."); Process p = Runtime.getRuntime().exec("C:/WINDOWS/system32/WarCraft/Warcraft III/Frozen Throne.EXE"); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception ex) { System.out.println("Failed loading L&F: "); System.out.println(ex); } new Run(); } }-- Ubuntu 8.04 (Linux) O.P.S. 512mb RAM
-- 2.66 Ghz Pentium Geforce NVidia 440 64mb
- 01-21-2009, 08:43 PM #5
and this is the error:
unreported exception java.lang.Exception; must be caught or declared to be trown || line: 32-- Ubuntu 8.04 (Linux) O.P.S. 512mb RAM
-- 2.66 Ghz Pentium Geforce NVidia 440 64mb
- 01-21-2009, 08:46 PM #6
if someone could try running this, but replacing the line:
Process p = Runtime.getRuntime().exec("C:/WINDOWS/system32/WarCraft/Warcraft III/Frozen Throne.EXE");
with something you have for example:
Process p = Runtime.getRuntime().exec("C:/Program Files/Microsoft Office/Word.EXE"); or any other program, it would be helpfull.-- Ubuntu 8.04 (Linux) O.P.S. 512mb RAM
-- 2.66 Ghz Pentium Geforce NVidia 440 64mb
Similar Threads
-
Calling a JFrame window from a command line program.
By new_2_java in forum New To JavaReplies: 7Last Post: 11-09-2008, 03:40 AM -
Simple JFrame Problem
By DC1 in forum New To JavaReplies: 4Last Post: 06-06-2008, 07:09 AM -
Help-would like JFRAME added to program
By tigerfan2 in forum New To JavaReplies: 1Last Post: 05-13-2008, 03:03 AM -
JFrame problem
By vassil_zorev in forum AWT / SwingReplies: 1Last Post: 01-25-2008, 02:53 AM -
JFrame problem
By saytri in forum New To JavaReplies: 6Last Post: 01-11-2008, 05:12 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks