LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2010, 11:05 PM   #1
Kakarot_Rathish
Member
 
Registered: Sep 2008
Posts: 35
Blog Entries: 1

Rep: Reputation: 15
calling constructor of a dialogbox in main using netbeans


In my project,Login window is created as a Dialog box.
So when i tried to call the constructor of Login from Main it was generating an error regarding the arguments passed.
I have not used any arguments when i called.

when i looked at the code,
the function was declared as

public Login(java.awt.Frame parent,boolean modal)

so when i call it from main(),what am i supposed to do ?

hope my query is understandable.

THANX
 
Old 03-29-2010, 08:55 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
How about you show us how you are currently calling it from main() and then we can see where you have gone wrong?
 
Old 03-31-2010, 05:36 AM   #3
Kakarot_Rathish
Member
 
Registered: Sep 2008
Posts: 35

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Quote:
Originally Posted by grail View Post
How about you show us how you are currently calling it from main() and then we can see where you have gone wrong?
===========================================================
// this is the constructor i want to call

public class UserLogin extends javax.swing.JDialog {

/** Creates new form UserLogin */
public UserLogin(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}



//and it has the main function

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
UserLogin dialog = new UserLogin(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
============================================================

// in the main function of the project,main.java i tried calling it using

UserLogin ul=new UserLogin();

//which reports an error as no such constructor

===========================================================
 
Old 03-31-2010, 06:44 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
That would be the correct error as you have written:

Quote:
UserLogin ul=new UserLogin();
While in the text above the constructor clearly takes two arguments:

Quote:
public UserLogin(java.awt.Frame parent, boolean modal)
 
1 members found this post helpful.
  


Reply

Tags
constructor, netbeans



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
not calling copy constructor on function return jhorvath Programming 7 09-22-2009 12:43 PM
g++ calling the deconstructor, and not the constructor in pass by value functions pilotmm Programming 1 07-21-2009 07:00 PM
Gtk+-2.0 Calling constructor [language C] Four Programming 3 05-30-2008 02:21 PM
calling a superclass constructor kpachopoulos Programming 1 09-04-2006 12:15 PM
MythTV Install: compile errors dialogbox.cpp shubb Linux - Software 0 09-14-2005 01:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration