Results 1 to 4 of 4
- 03-19-2009, 10:49 AM #1
How to call a class within a method
Hi people,
I have a program that has two classes and am trying to call one classes within a method.How can i do this coz its really confusing me
Below is my code
I am supposed to call the above class in another method which is in another class.Java Code:package MyXenonConc; import org.jdesktop.application.Action; /** * * @author MUNYA00M */ public class AboutBox extends javax.swing.JDialog { /** Creates new form AboutBox */ public AboutBox(java.awt.Frame parent) { super(parent); initComponents(); getRootPane().setDefaultButton(closeButton); } @Action public void closeAboutBox() { setVisible(false); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // Variables declaration - do not modify private javax.swing.JButton closeButton; private javax.swing.JLabel jLabel1; // End of variables declaration }
Anyone with an idea on how i can do thid??
your response will be highly appreciated
Thanx
- 03-19-2009, 11:10 AM #2
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
do your "call" means construct a class object in another class?
if yes,
import this call in the other class
AboutBox ab = new AboutBox(xxx);
- 03-19-2009, 11:20 AM #3
I want when a certain button is pressed,the about box class to be called and diplay the image in the frame
This is how i called the constructor
where exactly am i goin wrong????Java Code:private void AboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: AboutBox aboutBox = new AboutBox(javax.swing.JDialog); if (aboutBox == null) { aboutBox = new TrendAboutBox(mainFrame); aboutBox.setLocationRelativeTo(mainFrame); } }Last edited by Manfizy; 03-19-2009 at 11:57 AM.
- 03-19-2009, 12:34 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
This is wrong. In the AboutBox class you don't have a constructor with the parameter JDialog. There is with awt Frame. You have to modify either of them on your application.Java Code:AboutBox aboutBox = new AboutBox(javax.swing.JDialog);
Similar Threads
-
Call java method from jsp
By saiphani723 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 02-25-2009, 11:21 AM -
How to call method in servet by using JSP?
By frankjava1 in forum Java ServletReplies: 2Last Post: 10-24-2008, 04:20 AM -
[SOLVED] Call method from another class name
By antgaudi in forum New To JavaReplies: 3Last Post: 10-15-2008, 12:33 AM -
Call Java Method
By hussainzim in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-15-2008, 07:22 AM -
cannot call private method from static method
By jon80 in forum New To JavaReplies: 3Last Post: 05-07-2008, 08:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks