Table and abstract classes
Hello,
I have a window with a JMenu. In addition, a class retains values int and double. I use it in tabular form:
Code:
val [] = new TDP val [];
From the window menu, call TDP [i]. setval (int. ..), but as Action event is an abstract class, it does not work. What should I do? (In fact, I try to transfer values from one window to JSpinners this val). Do I create a special class for this? I can not find a solution for this. I thin I have a problem in using the tables with the abstract class. If you have any suitable solution for this then please post back. Thanks in advance.
Re: Table and abstract classes
Hello,
I do not know of which problem are you talking about. And I do not see where your problem is the menu. See, the code below , I do not think that there is any problem in it.
Code:
JMenuItem jmenu = new JMenuItem("button menu");
jmenu.addActionListener(
new ActionListener() {
Public void ActionPerformed(ActionEvent e) {
TDP[i]. setval(int...);
}
}
);
Re: Table and abstract classes
Hello,
I think I have a similar kind of a problem with my program. I thin we must instantiate the TDP [] method in the Action Event in your case , and not in the constructor of the window. Here, it is recognized. It will not be initialized with each new manip menus. I guess I am correct here. I'm really a conflicted between the code and the abstract classes. So, I can not say what exactly is the solution for this. Still , I will try on it and if i found a solution for this then I will post back.
Re: Table and abstract classes
Hello,
I think you can try to create a clone () method in your object val.
Code:
protected val clone() {
val v = new val();
v.setRotVal(RotVal);
v.setSymXVal(SymXVal);
return v;
}
And instead of:
Code:
v.setRotVal(RotVal);
v.setSymXVal(SymXVal);
You put:
Code:
val v = new val();
v.setRotVal(RotVal);
v.setSymXVal(SymXVal);
TDP[i] = Vt.clone();
Re: Table and abstract classes
Hello,
I think it's in the design of these tables of values that the problem is in effect. One can easily instantiate a Val, do (during the ActionEvent method):
Code:
val v = new val();
v.setRotVal(RotVal);
v.setSymXVal(SymXVal);
It works very well, but TDP [i] = v.clone () is called "inconsistent" with the compiler. (whether in the ActionEvent, or outside for that matter!) I'll give some thought to your explanations and use your clone method.
Re: Table and abstract classes
Hello,
I think you can try the following code
Code:
...
Public class val {
...
protected val clone()
throws CloneNotSupportedException {
val v = new val();
v.setRotVal(RotVal);
v.setSymXVal(SymXVal);
return v;
}
...
}