File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes load a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "load a class" Watch "load a class" New topic

load a class

Sammer Meer

Joined: Mar 24, 2004
Posts: 19
I have a program with a combo box, when i choose an item from the combo my program must go to a certain class and invoke a method in it , how can i do that? can i invoke this method in that certain class?

Ai no corrida..That's where I am<br />You send me there<br />Your dream is my command...
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Not got the problem. please explain briefly. what type of application you are creating? is it web applicatoin with jsp or servlet? what type of method you want to call.
You can call any method just by creating the object of that class.
Sammer Meer

Joined: Mar 24, 2004
Posts: 19
No, it's an application that deals with Barcodes.. I have to make for each standard a jar file that contains the classes necessary for encoding/decoding related to that standrd.An obligatory class (that must exist in every valid jar file) is a class derived JPanel.. I want to load this class from a certain jar file when the user chooses a standard (that's related to that jar file) from a ComboBox, and then I want to make an instance of that class (which extends JPanel) and add this panel to my frame..
Kush Kush

Joined: Apr 27, 2004
Posts: 11
Class.forName(path to your class)
It will load ur class.
Note Class is a Class itself and forName is static method.

Smile with JAVA
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I'm guessing a little that what you're trying to figure out is mostly GUI-related - eg. handling events, displaying panels.
As such, I'm moving this to the Swing / JFC / AWT forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
you must have main class for control UI and UI module class is base class for create UI in each panel

Class extends UIModule

Java Developer, Thailand
I agree. Here's the link:
subject: load a class
It's not a secret anymore!