What happen when a JFrame in a class is declared as static?

Posted on 2004-11-13
Last Modified: 2010-03-31
What complications if i m to declare this frame as static?
Is it a bad taste(bad programming) to declare a JFrame in a class as static.

Background information
If I had a class called, ReservationForm. In it, I declared a JFrame frame1 to setup a JFrame components with some the swing components.

The reason I declared the frame in ReservationForm class as static as I wanted to remove the frame1 ONLY after user has click on a submit button in another JFrame (call frame2).

What I did:
I wrote a method - public void close() in frame1. I can only dispose this frame1 when user click a submit button in frame2. Immediately after disposing frame1, it display the frame1 again with data in the JTable updated.

Question by:coffee_bean
    1 Comment
    LVL 24

    Accepted Solution

    Not very much.
    Usually a JFrame stands as long as the application.
    If you want to drop it, put the static reference to null after you disposed of it.
    So ,nothing special about a static reference.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    hasOne  challenge 59 66
    advance java 4 36
    strDist challenge 35 72
    Core Java. What output will be and why ? 6 41
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now