Results 1 to 3 of 3

Thread: How to use getContentPane() method in Swing

  1. #1
    Join Date
    Jun 2009
    Posts
    45

    How to use getContentPane() method in Swing

    I am newbie to the JAVA programming language I have requirement to apply getContentPane() method in my program but i have very less information regarding it, so if anyone has any idea or knowledge about it please let me know.

    Thanks for your Help

  2. #2
    Join Date
    Mar 2008
    Posts
    232

    Re: How to use getContentPane() method in Swing

    The frame / dialog / window itself has other internal components - like the content pane. getContentPane() is a method that returns a container that is where you usually add all of your components instead of adding Component objects directly to a window such as a JFrame or a JDialog.

    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;

    To import the above mentioned method you need to import the above functions in your program.

  3. #3
    Join Date
    Jan 2009
    Posts
    99

    Re: How to use getContentPane() method in Swing

    The swing top-level containers all have a single root component (JRootPane, see here) which holds several, layered sub-containers (content pane, layered pane, glass pane). getContentPane(): frames are wht make up windows in your UI and these frames are made up from an object which has 3 layers to it which are called: rootpane, contentpane and glasspane from lowest to highest. Generally everything you see in your ui goes into the contentpane. This pane is just a container object which holds everything and this is what your getting from this method. Here you can have the following programming format for getContentPane
    Code:
    public void add(Component component, Object constraints)  
    {  
        getContentPane().add(component, constraints);  
    }

Similar Threads

  1. Method overriding versus method hiding in C#
    By ^MALARVIZHI^ in forum Software Development
    Replies: 4
    Last Post: 25-12-2010, 05:25 AM
  2. What are JFC and Swing?
    By DANIEL 602 in forum Software Development
    Replies: 5
    Last Post: 14-02-2010, 03:11 AM
  3. Is it possible to call destroy() method within init() Method?
    By Level8 in forum Software Development
    Replies: 3
    Last Post: 10-12-2009, 07:36 AM
  4. What is method overriding and method overloading in java
    By beelow in forum Software Development
    Replies: 3
    Last Post: 17-11-2009, 07:20 AM
  5. Java: How can I call one method in another method?
    By biohazard 76 in forum Software Development
    Replies: 3
    Last Post: 16-07-2009, 07:12 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
  •