Results 21 to 39 of 39
Thread: [SOLVED] Chm
- 07-10-2008, 09:04 AM #21
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-10-2008, 09:06 AM #22
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Nice to here that. If you solve the question, don't forget to mark the thread as solved. :)
- 07-10-2008, 09:08 AM #23
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-10-2008, 09:09 AM #24
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-10-2008, 09:11 AM #25
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You want to display a message box or a dialog? On any of them, simply call them in correct menu event. If you have done the previous work fine this couldn't be a difficult one at all.
- 07-10-2008, 09:27 AM #26
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
Sir i call dialog ..Here is code.But it is not working on the way.When i select the file name through dialog then it is not open..
Java Code:public void actionPerformed(ActionEvent e) { try { FileDialog fd = new FileDialog ( new Frame ( ) , "Open file...", FileDialog.LOAD ) ; fd.setFile ( "*.log" ) ; fd.show ( ) ; Runtime.getRuntime().exec("cmd /c start c:\\"); } catch (Exception x) { x.printStackTrace(); } } }
- 07-10-2008, 09:50 AM #27
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
You don't need Runtime. And why did you not stick with JFileChooser rather than the older and not so good FileDialog?
Simply let the user choose a file with JFileChooser, then call Desktop.open(<file from filechooser>).
Once again, what is so hard. I mentioned the Desktop class in my very first post and provided a link to it and still, nowehere in any of your posted attempts, has it shown up anywhere. Do you always simply ignore what people tell you?
- 07-10-2008, 10:25 AM #28
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-10-2008, 12:15 PM #29
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
SIr plz tell me how can i do ..
- 07-10-2008, 12:24 PM #30
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
So switch out using Desktop.open with your Runtime stuff, using, however, the array command type, rather than the String command type (just don't forget to start it in a separate thread with an additional thread for both the command output and error streams otherwise it may hang if it produces any output), but still using the file returned from the JFileChooser.
But that was a piece of information that you should have spit out a bit earlier.
- 07-10-2008, 12:39 PM #31
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-10-2008, 01:06 PM #32
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
The fact that you were using 1.5
We can only advise you on things that we are aware of. If we advise you to use a Class from 1.6 that does not exist in 1.5, and you are using 1.5, but don't say anything, than all we do is run around in circles with us repeating what we've already said, and you continually running down dead ends and coming back complaining.
On your second post you should have said "I'm using 1.5" rather than waiting until just now to do so.
- 07-10-2008, 01:22 PM #33
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
Ok sir,one thing i want to know what can i change in this code for run perfect.I mean according to need..Code is here
Plz help me SirJava Code:public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog ( new Frame ( ) , "Log", FileDialog.LOAD ) ; fd.setFile ( "*.log" ) ; fd.show ( ) ; try { Runtime.getRuntime().exec("cmd /c start \\"); } catch (Exception x) { x.printStackTrace(); } }
- 07-10-2008, 01:32 PM #34
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Use JFileChooser, not FileDialog. And execute the proper command in the runtime exec method (and use the array form of it, not the string form, otherwise a file with a space in the name is going to mess it up).
See
JFileChooser (Java 2 Platform SE 5.0)
Runtime (Java 2 Platform SE 5.0)
How to Use File Choosers (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)
When Runtime.exec() won't - Java World
- 07-10-2008, 02:01 PM #35
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-11-2008, 06:06 AM #36
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
- 07-11-2008, 02:06 PM #37
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0
Sir now i am open file directly from directory..
through this ,it is open a directori.Java Code:Runtime.getRuntime().exec("cmd /c start \\");
But i want to open a some specific path like "\\Program Files\\Internet Explorer" then i am geting error. So how can i set the set.
Plz help me
- 07-11-2008, 02:44 PM #38
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Oh come on. Do you know what program you have to use to view a "chm" file (whatever the heck that is)?
If so, use that programs executable as the command with the file returned from JFileChooser as an argument, instead of "start \\" in that exec statement.
And use the form of the exec method that takes an array rather than a string (and those links I posted earlier have more than enough info for you to figure out how to use that).
If you don't know which program it is, then ask Microsoft (or whoever it is that you get these "chm" files from).
- 07-12-2008, 07:05 AM #39
Senior Member
- Join Date
- Jun 2008
- Posts
- 121
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks