Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-03-2010
Member
 
Join Date: Dec 2009
Posts: 263
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.
Reply With Quote
  #2  
Old 03-03-2010
Member
 
Join Date: Nov 2009
Posts: 347
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...);
      }
   }
);
Reply With Quote
  #3  
Old 03-03-2010
Member
 
Join Date: Dec 2009
Posts: 204
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.
Reply With Quote
  #4  
Old 03-03-2010
Member
 
Join Date: Nov 2009
Posts: 446
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();

Last edited by cyber-noob : 03-03-2010 at 10:50 AM.
Reply With Quote
  #5  
Old 03-03-2010
Member
 
Join Date: Dec 2009
Posts: 263
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.
Reply With Quote
  #6  
Old 03-03-2010
Member
 
Join Date: Nov 2009
Posts: 359
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;
	}
...
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Table and abstract classes"
Thread Thread Starter Forum Replies Last Post
Difference between Abstract classes and Interfaces in C# Gallard Software Development 8 21-05-2012 11:58 AM
Link a Table to another Table to Drop Down In Main Table himeshRES Windows Software 6 11-12-2010 02:01 PM
Sort a table for several classes New ID Software Development 5 13-02-2010 04:19 AM
Use of abstract classes ScarFace 01 Software Development 5 25-01-2010 09:07 AM
Abstract Classes in PHP5 nonose Software Development 2 16-06-2009 02:33 PM


All times are GMT +5.5. The time now is 05:22 AM.