i have a question..
do i have to use many static variable or method in Swing/Swt/Awt application?..
example i have method like this instance : (which would be accessed from another JDialog)
do i have to use static variable also?..
assume that, i have 2 JDialog, which named JDialog1 and JDialog2..
JDialog2 would be opened by click a button on JDialog1..
and in JDialog2 has JTable.. when user double click row in JTable, then the values would be sent to JTextField in JDialog1..
so i provide static JTextfield..
and the code like this example :
what i have done is true or not?
Correct me if iam wrong..
Thanks in advance ..
Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
I definitely would not do that. Instead, make the methods regular instance methods (so non-static), and provide the second JDialog a reference to the first JDialog. You can then use this reference to call the methods.
The new JDialog class gets a reference field to class JDialog1, which you set in the constructor:
Created from a JDialog1 instance:
Your code then simply calls dialog1.xxx instead of JDialog1.xxx - using the new private field instead of static calls.
how about if there are 3 JDialogs or more..
how to share that JDialog?..
i want to use only one JDialog so i have to share JDialog2, which would be accessed in another JDialog.. (actually we could create another JDialog which has contents like JDialog2, but i wouldn't create like that, it would magnify the Jar file which would be created)
i have created JDialog2 to show all of the Products data..
then, that JDialog2 would be accessed in PurchasingDialog, or TradingDialog..
i want to distinguish whether the JDialog2 called by PurchasingDialog or TradingDialog..
is it possible?
Thanks in advance sir..
subject: Swing with Many static variable and method