Results 1 to 2 of 2
  1. #1
    alkismavridis is offline Member
    Join Date
    Oct 2011
    Athens, Greece
    Rep Power

    Default Threads and subclasses


    I want to create a thread inside the actionPerformed method of a "JFrame extends" class, that will run a spesific method.

    How can i do that without messing with anonymus classes?
    I thought to implement Runnable interface, to include my run methode and finally to create the new thead with the object that my class creates, which will be Runnable.
    But this way i have to create a heavy object which has many fields and swing components, for simply creating a thread..

    Does something more convenient exists??


  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Threads and subclasses

    do that without messing with anonymus classes?
    Anonymous classes are for quick and easy creation of a class. If that is a problem then,
    You can always make a separate class with the full definition.
    An inner class will allow you to get to the outer class's variables.

Similar Threads

  1. need help with subclasses
    By thorobred in forum New To Java
    Replies: 6
    Last Post: 02-19-2011, 05:34 AM
  2. Dynamic Subclasses?
    By MrFish in forum Advanced Java
    Replies: 5
    Last Post: 11-07-2010, 01:28 AM
  3. Lost with subclasses
    By vinyacam in forum New To Java
    Replies: 3
    Last Post: 05-09-2010, 07:12 PM
  4. Generics and subclasses
    By Sven in forum Advanced Java
    Replies: 1
    Last Post: 12-22-2008, 06:06 PM
  5. Hibernate subclasses
    By Ed in forum JDBC
    Replies: 2
    Last Post: 07-02-2007, 04:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts