problem accessing the parent class


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: problem accessing the parent class

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Posts
    16

    Angry problem accessing the parent class

    Hei, I have the following problem within my java application:

    I have a Main class that executes when I open the containing .jar file.
    In Main I create a new JFrame, then I show it, in the following way: I have a class that extends JFrame, named "Interfata".

    Code:
    Interfata f = new Interfata();
    f.setVisible(true);
    Then, in Main class I wrote this function
    Code:
    public static void setLook(int tip)
    to change the appearance of the application, but I don't know how to access it from f (Interfata object).
    Practically, I need to access from a class, one function that resides in the class that instanciated that class.

    If anyone has a modality to solve this, I would apreciate it very much.
    Thanks!

  2. #2
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    1-its static , you can call YourMainClass.setLook(...) .
    2-for non static ones , you may put a instance variable into other class (Interfata ) and set it from main class. ( f.setMainClass( this ) )
    3-if you define Interfata as an "inner class" ,
    you can use every method or variable of the outer class (even private ones.)

  3. #3
    Join Date
    Sep 2005
    Posts
    16
    Thanks very much mr1yh1, it worked...

  4. #4
    Join Date
    Sep 2005
    Posts
    16
    Ow... it looks like I have one more problem:
    My function changes the lookAndFeel property.. and it changes.. partially. But the main window looks like a hibryd of the windows and metal themes. Is there a refresh.. or something like that function available ?

    Thanks.

Similar Threads

  1. Problem with WebClient class
    By news://news.devx.com in forum .NET
    Replies: 1
    Last Post: 03-16-2003, 02:37 AM
  2. Replies: 5
    Last Post: 10-17-2002, 02:58 PM
  3. Replies: 3
    Last Post: 07-23-2001, 12:05 PM
  4. Calling base class methods
    By GR in forum Java
    Replies: 1
    Last Post: 11-09-2000, 06:38 PM
  5. Replies: 1
    Last Post: 04-04-2000, 07:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center