Results 1 to 6 of 6

Thread: Table and abstract classes

  1. #1
    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.

  2. #2
    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...);
          }
       }
    );

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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;
    	}
    ...
    }

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,400,992.17404 seconds with 17 queries