|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

07-07-2008, 03:20 PM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
|
[SOLVED] Chm
Hi All
How can i open a chm file through menu item.Plz help me..
|
|

07-07-2008, 06:51 PM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 317
|
|
|
|
|

07-08-2008, 05:57 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,543
|
|
|
Yes Sarinam, Google is the best place. You can find large number of examples on the web. At least try one of them and ask any question if you stuck with them.
More important thing is, pay attention on what masijade says.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-09-2008, 07:54 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
Yes Sarinam, Google is the best place. You can find large number of examples on the web. At least try one of them and ask any question if you stuck with them.
More important thing is, pay attention on what masijade says.
Hello Sir
Now i am abel to create a menu item but don't know how i impliment .chm file.Sir plz help me
|
|

07-09-2008, 08:24 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,543
|
|
|
What you mean implement? Adding click events and stuff are you looking?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-09-2008, 08:54 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
What you mean implement? Adding click events and stuff are you looking?
Yes sir adding click event....
|
|

07-09-2008, 09:03 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 317
|
|
|
Did you read those two tutorials and the API docs for Desktop that I posted?
The last one shows you how to create menus and add ActionListeners to the Items.
The second one shows you how to write an ActionListener.
The first one (the API doc) shows you a class you can use to allow a system to "open" a "chm" file with the "default" program assigned to handle it.
So, write an ActionListener that calls desktop and attach it to your menu item.
That's it.
|
|

07-09-2008, 09:19 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by masijade
Did you read those two tutorials and the API docs for Desktop that I posted?
The last one shows you how to create menus and add ActionListeners to the Items.
The second one shows you how to write an ActionListener.
The first one (the API doc) shows you a class you can use to allow a system to "open" a "chm" file with the "default" program assigned to handle it.
So, write an ActionListener that calls desktop and attach it to your menu item.
That's it.
Can you give me some example code..
|
|

07-09-2008, 09:32 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 317
|
|
|
Post your attempt at it, and we will help you correct it, but we are not going to do it for you. Those tutorials have enough code snippets as it is, anyway. And a little Google searching, I can guarantee, will turn up a code snippit for Desktop.
|
|

07-09-2008, 09:36 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,543
|
|
|
Yep, shows your code where you stuck with and try to get our members help. I'm sure that too, you can easily find an example on the web related to your application.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-09-2008, 09:48 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
Yep, shows your code where you stuck with and try to get our members help. I'm sure that too, you can easily find an example on the web related to your application.
Sir i just create a menu and i havn no idia how i add chm..here is code
import java.awt.*;
import java.awt.event.*;
public class MainWindow extends Frame {
public MainWindow() {
super("Menu Window");
setSize(400, 400);
FileMenu fileMenu = new FileMenu(this);
HelpMenu helpMenu = new HelpMenu(this);
MenuBar mb = new MenuBar();
mb.add(fileMenu);
mb.add(helpMenu);
setMenuBar(mb);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
exit();
}
});
}
public void exit() {
setVisible(false);
dispose();
System.exit(0);
}
public static void main(String args[]) {
MainWindow w = new MainWindow();
w.setVisible(true);
}
}
class FileMenu extends Menu implements ActionListener {
MainWindow mw;
public FileMenu(MainWindow m) {
super("File");
mw = m;
MenuItem mi;
add(mi = new MenuItem("Open"));
mi.addActionListener(this);
add(mi = new MenuItem("Close"));
mi.addActionListener(this);
add(mi = new MenuItem("Exit"));
mi.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
String item = e.getActionCommand();
if (item.equals("Exit"))
mw.exit();
else
System.out.println("Selected FileMenu " + item);
}
}
class HelpMenu extends Menu implements ActionListener {
MainWindow mw;
public HelpMenu(MainWindow m) {
super("Help");
mw = m;
MenuItem mi;
add(mi = new MenuItem("Basics"));
mi.addActionListener(this);
add(mi = new MenuItem("Advanced"));
mi.addActionListener(this);
addSeparator();
add(mi = new CheckboxMenuItem("Manual"));
mi.addActionListener(this);
Menu subMenu = new Menu("Miscellaneous");
subMenu.add(mi = new MenuItem("Help"));
mi.addActionListener(this);
subMenu.add(mi = new MenuItem("Other Option"));
mi.addActionListener(this);
add(subMenu);
}
public void actionPerformed(ActionEvent e) {
String item = e.getActionCommand();
if (item.equals("Basics"))
System.out.println("Basics");
else if (item.equals("Help"))
System.out.println("Help");
}
}
Sir here how can i add chm..
|
|

07-09-2008, 10:09 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 317
|
|
|
When the "actionCommand" equals "Open", use JFileChooser to have the user select the file then call Desktop.open(file). What is so hard here?
|
|

07-09-2008, 02:29 PM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by masijade
When the "actionCommand" equals "Open", use JFileChooser to have the user select the file then call Desktop.open(file). What is so hard here?
sir i am useing fileChooser like this.Can you how can i open now chm file.Becouse here code is working but file is not open.
private class OpenAction implements ActionListener {
public void actionPerformed(ActionEvent ae) {
int retval = m_fileChooser.showOpenDialog(m_Frame);
if (retval == JFileChooser.APPROVE_OPTION) {
File chm = m_fileChooser.getSelectedFile();
}
}
}
Plz help me
|
|

07-10-2008, 05:22 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,543
|
|
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-10-2008, 07:15 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
Sir i need some code example..
Plz give me some code example
Help me sir
|
|

07-10-2008, 09:26 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
Sir now i am abel to open a file from drive.But it is open file direct from drive.But i need to open file through menuitem.here is code which is open file..Plz help me
public class Main {
public Main() {
}
public static void main(String[] args) {
try {
//Runtime.getRuntime().exec("cmd /c start myfile.doc");
//Runtime.getRuntime().exec("cmd /c start \"myfile.doc\"");
//Runtime.getRuntime().exec("cmd /c start ma.txt");
Runtime.getRuntime().exec("cmd /c startc:\\ma.txt");
//Runtime.getRuntime().exec("cmd /c start myfile.xls");
//Runtime.getRuntime().exec("cmd /c start myfile.pdf");
//Runtime.getRuntime().exec("myfile.doc");
}
catch (Exception x) {
x.printStackTrace();
}
catch (Error e) {
e.printStackTrace();
}
}
}
|
|

07-10-2008, 09:30 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,543
|
|
|
See, after few attempts you got the things. Now what you have to do is on menu item click event, do the same process. Do you know how to add events to menu items?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-10-2008, 09:46 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
See, after few attempts you got the things. Now what you have to do is on menu item click event, do the same process. Do you know how to add events to menu items?
Sir it is working but i want to add some option for browser..
|
|

07-10-2008, 09:57 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Originally Posted by Eranga
See, after few attempts you got the things. Now what you have to do is on menu item click event, do the same process. Do you know how to add events to menu items?
Sir this code is working but when i implements ActionListene on my original code then i got error. Here is my code how can i add ActionListene in this code.
import java.awt.*;
public class MainMenu
{
Frame m_Frame = null;
boolean m_fInitialized = false;
MenuBar mb;
MenuItem MN_EXIT;
Menu m3;
Menu m8;
MenuItem ID_HELP_ABOUT;
MenuItem ID_HELP_TOPICS;
// Constructor
//--------------------------------------------------------------------------
public MainMenu (Frame frame)
{
m_Frame = frame;
}
// Initialization.
//--------------------------------------------------------------------------
public boolean CreateMenu()
{
// Can only init controls once
//----------------------------------------------------------------------
if (m_fInitialized || m_Frame == null)
return false;
// Create menubar and attach to the frame
//----------------------------------------------------------------------
mb = new MenuBar();
m_Frame.setMenuBar(mb);
// Create menu and menu items and assign to menubar
//----------------------------------------------------------------------
//
// MN_EXIT = new MenuItem("Exit");
m3 = new Menu("Settings");
mb.add(m3);
MN_EXIT = new MenuItem("Exit");
m3.add(MN_EXIT);
m8 = new Menu("Help");
mb.add(m8);
ID_HELP_TOPICS=new MenuItem("Help Topics");
m8.add(ID_HELP_TOPICS);
ID_HELP_ABOUT = new MenuItem("About");
m8.add(ID_HELP_ABOUT);
m_fInitialized = true;
return true;
}
}
|
|

07-10-2008, 10:02 AM
|
|
Senior Member
|
|
Join Date: Jun 2008
Posts: 121
|
|
Error is
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The type MainMenu must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
at main.MainMenu.actionPerformed(MainMenu.java:10)
at java.awt.MenuItem.processActionEvent(Unknown Source)
at java.awt.MenuItem.processEvent(Unknown Source)
at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
at java.awt.MenuComponent.dispatchEvent(Unknown Source)
at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
at java.awt.MenuComponent.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
| | | |