LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   calling constructor of a dialogbox in main using netbeans (https://www.linuxquestions.org/questions/programming-9/calling-constructor-of-a-dialogbox-in-main-using-netbeans-798543/)

Kakarot_Rathish 03-28-2010 11:05 PM

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

grail 03-29-2010 08:55 PM

How about you show us how you are currently calling it from main() and then we can see where you have gone wrong?

Kakarot_Rathish 03-31-2010 05:36 AM

Quote:

Originally Posted by grail (Post 3917374)
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

===========================================================

grail 03-31-2010 06:44 AM

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)


All times are GMT -5. The time now is 07:50 PM.