Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-21-2009, 06:10 AM
linux1man's Avatar
Member
 
Join Date: Nov 2008
Posts: 39
Rep Power: 0
linux1man is on a distinguished road
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!
__________________
-- Ubuntu 8.04 (Linux) O.P.S. 512mb RAM
-- 2.66 Ghz Pentium Geforce NVidia 440 64mb

Last edited by linux1man; 01-21-2009 at 06:17 AM.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-21-2009, 06:59 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,445
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Couldn't find the attachment here. Most probably you cannot do that. Better to copy-pate the error message here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-21-2009, 11:35 AM
makpandian's Avatar
Senior Member
 
Join Date: Dec 2008
Location: Chennai
Posts: 253
Rep Power: 2
makpandian is on a distinguished road
Default
i coudn't understand what problem u had.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-21-2009, 09:40 PM
linux1man's Avatar
Member
 
Join Date: Nov 2008
Posts: 39
Rep Power: 0
linux1man is on a distinguished road
Default
ok, this is the code

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
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-21-2009, 09:43 PM
linux1man's Avatar
Member
 
Join Date: Nov 2008
Posts: 39
Rep Power: 0
linux1man is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-21-2009, 09:46 PM
linux1man's Avatar
Member
 
Join Date: Nov 2008
Posts: 39
Rep Power: 0
linux1man is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a JFrame window from a command line program. new_2_java New To Java 7 11-09-2008 04:40 AM
Simple JFrame Problem DC1 New To Java 4 06-06-2008 08:09 AM
Help-would like JFRAME added to program tigerfan2 New To Java 1 05-13-2008 04:03 AM
JFrame problem vassil_zorev AWT / Swing 1 01-25-2008 03:53 AM
JFrame problem saytri New To Java 6 01-11-2008 06:12 PM


All times are GMT +2. The time now is 07:00 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org