Results 1 to 6 of 6
  1. #1
    linux1man's Avatar
    linux1man is offline Member
    Join Date
    Nov 2008
    Posts
    39
    Rep Power
    0

    Question 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

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Couldn't find the attachment here. Most probably you cannot do that. Better to copy-pate the error message here.

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    449
    Rep Power
    6

    Default

    i coudn't understand what problem u had.

  4. #4
    linux1man's Avatar
    linux1man is offline Member
    Join Date
    Nov 2008
    Posts
    39
    Rep Power
    0

    Default

    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

  5. #5
    linux1man's Avatar
    linux1man is offline Member
    Join Date
    Nov 2008
    Posts
    39
    Rep Power
    0

    Default

    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

  6. #6
    linux1man's Avatar
    linux1man is offline Member
    Join Date
    Nov 2008
    Posts
    39
    Rep Power
    0

    Default

    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

  1. Calling a JFrame window from a command line program.
    By new_2_java in forum New To Java
    Replies: 7
    Last Post: 11-09-2008, 03:40 AM
  2. Simple JFrame Problem
    By DC1 in forum New To Java
    Replies: 4
    Last Post: 06-06-2008, 07:09 AM
  3. Help-would like JFRAME added to program
    By tigerfan2 in forum New To Java
    Replies: 1
    Last Post: 05-13-2008, 03:03 AM
  4. JFrame problem
    By vassil_zorev in forum AWT / Swing
    Replies: 1
    Last Post: 01-25-2008, 02:53 AM
  5. JFrame problem
    By saytri in forum New To Java
    Replies: 6
    Last Post: 01-11-2008, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •