Reputation: 27
I have to create a login JFrame
and I need username in all the JDialog
s that are owned by JFrame
. How should I implement this?
I tried the following code.
class MyFrame extends Jframe {
public getusername() {
return username;
}
createGui() {
JButton btnsubmit;
btnsubmit.addActionListener(new ActionListener() {
void actionPerformed(ActionEvent e) {
new MyJDialog(MyFrame.this);
}
});
}
}
in the JDialog
I am trying to use getusername()
in this way
MyJDialog(JFrame frame) {
super(frame);
String us=frame.getusername();
}
but it is not working. What am I doing wrong?
Upvotes: 2
Views: 373
Reputation: 347314
getusername
is not a valid method for JFrame
.
You should be specifying the concrete implementation within the dialogs constructor...
MyJDialog(MyFrame frame) {...}
Upvotes: 2