Results 1 to 4 of 4

Thread: swing events

  1. #1
    chitra is offline Member
    Join Date
    Sep 2008
    Posts
    1
    Rep Power
    0

    Question swing events

    i am using net beans ide...how to show previously created frame by clicking menu item..i wrote the coding like that..


    private void paddnewmenuitemMouseClicked(java.awt.event.MouseEv ent evt) {
    patientdetails.pack();
    patientdetails.setVisile(true);
    }

    but it provide the following warning message..
    Non-static method pack() can not be referenced from a static context.

    pls help me.thanks in advance..

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes you can't call the pack() within the static contest. Actually you should do it within the previously constructed frame. No need to do it here, and you can't do it also.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    This actually has little to do with Swing and everything to do with understanding and respecting the differences between the static world and the non-static or instance world -- a cornerstone of OOPS programming. I suggest you read up on this including this series of tutorials from Sun: Lesson: Object-Oriented Programming Concepts.

    Good luck.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    This actually has little to do with Swing and everything to do with understanding and respecting the differences between the static world and the non-static or instance world -- a cornerstone of OOPS programming. I suggest you read up on this including this series of tutorials from Sun: Lesson: Object-Oriented Programming Concepts.

    Good luck.
    Correct. :) I just try to pointed related to swing. Because he's try to clarify on that way, I think.

Similar Threads

  1. Need Help With Button Events
    By adlb1300 in forum New To Java
    Replies: 5
    Last Post: 11-03-2007, 05:36 AM
  2. Help with keyboard events?
    By Bibendum in forum New To Java
    Replies: 2
    Last Post: 11-02-2007, 02:51 AM
  3. To capture events with struts
    By Ed in forum Web Frameworks
    Replies: 2
    Last Post: 07-04-2007, 06:01 AM
  4. Help, events in Jbutton class
    By Heather in forum Java Applets
    Replies: 2
    Last Post: 06-30-2007, 04:32 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
  •