Results 1 to 10 of 10
Like Tree4Likes
  • 2 Post By KevinWorkman
  • 1 Post By KevinWorkman
  • 1 Post By Fubarable

Thread: Container/Panel/WIndow/Frame

  1. #1
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

    Default Container/Panel/WIndow/Frame

    Hello everyone,
    I'm reading lots of guides and each of them uses a diffrent Container or the Container it self to represent the program window.
    I know that Frame is a sub-class of Window, Window and Panel are sub-classes of Container.
    What is the diffrence?When I have to use the frame, panel, window or the big father .. the container.

    Thanks in advanced.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Container/Panel/WIndow/Frame

    It really depends on what you're trying to do. But first off, are you using AWT or Swing? If you don't know which to use, use Swing (JFrame, not Frame, JPanel, not Panel). Back to your question, you use each when you need it- you need a JFrame to open a window, to which you add JPanels as Containers of other Components (which themselves might be JPanels).
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

    Default Re: Container/Panel/WIndow/Frame

    My english is not perfect, so correct me if I'm wrong.
    The frame is the "Main Window" and the Panels are kind of window inside a window?
    So if I want to create a frame that has just one panel, can I just use the frame?or I have to create a panel and add it to the frame?

    I'm using the AWT package because I want to create a flexiable gui(In terms of design of course).

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Container/Panel/WIndow/Frame

    Quote Originally Posted by tnrh1 View Post
    I'm using the AWT package because I want to create a flexiable gui(In terms of design of course).
    If that's your goal, you should be using Swing.

    Quote Originally Posted by tnrh1 View Post
    My english is not perfect, so correct me if I'm wrong.
    The frame is the "Main Window" and the Panels are kind of window inside a window?
    A JFrame is a main window- it contains a title bar as well as buttons for minimizing, closing, etc. A JPanel is a Component within a JFrame that may or may not contain other Components. JPanels can be placed into top-level Containers such as JFrames and JApplets, but they can also be placed into sub-Containers such as other JPanels.

    Recommended reading: How to Use Panels (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    Quote Originally Posted by tnrh1 View Post
    So if I want to create a frame that has just one panel, can I just use the frame?or I have to create a panel and add it to the frame?
    Every JFrame has a content pane, which in reality is a JPanel. When you add something to your JFrame, you're actually adding it to the JFrame's content pane.
    camickr and tnrh1 like this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

    Default Re: Container/Panel/WIndow/Frame

    Thank you so much.
    And when I said "flexiable" I meant that the components designe will be changed in every OS (which is not possible with swing as far as I know).

    Thanks again.

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Container/Panel/WIndow/Frame

    Quote Originally Posted by tnrh1 View Post
    Thank you so much.
    And when I said "flexiable" I meant that the components designe will be changed in every OS (which is not possible with swing as far as I know).

    Thanks again.
    I'm not sure I know what you mean. I believe you can accomplish this by using the correct look and feel.
    Fubarable likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: Container/Panel/WIndow/Frame

    And when I said "flexiable" I meant that the components designe will be changed in every OS (which is not possible with swing as far as I know).
    Thats what a LAF is for. See: How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)

    This also gives you access to more components like JTable, JTree.

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

    Default Re: Container/Panel/WIndow/Frame

    Quote Originally Posted by KevinWorkman View Post
    I'm not sure I know what you mean. I believe you can accomplish this by using the correct look and feel.
    Exactly. I think that our original poster's assumptions are way off the mark.

  9. #9
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

    Default Re: Container/Panel/WIndow/Frame

    Ok then I guess I will use the Swing package from now on..
    But I don't get it, if the swing package is better then the awt .. why it exists?

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

    Default Re: Container/Panel/WIndow/Frame

    Quote Originally Posted by tnrh1 View Post
    Ok then I guess I will use the Swing package from now on..
    But I don't get it, if the swing package is better then the awt .. why it exists?
    AWT was Java's original graphics library but this has been largely superseded by Swing (which is partly built on top of AWT) since Java 1.2.
    tnrh1 likes this.

Similar Threads

  1. Replies: 1
    Last Post: 07-07-2011, 09:38 PM
  2. Replies: 3
    Last Post: 03-24-2011, 07:18 AM
  3. How to center a window with Container
    By fernandoj in forum AWT / Swing
    Replies: 5
    Last Post: 05-10-2010, 12:00 AM
  4. how can i move one frame window to another window
    By santhosh_el in forum AWT / Swing
    Replies: 8
    Last Post: 06-10-2009, 04:36 PM
  5. How to place panel into frame
    By vivek_9912 in forum AWT / Swing
    Replies: 2
    Last Post: 11-20-2007, 12:21 AM

Posting Permissions

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