Results 1 to 3 of 3
  1. #1
    DrMadolite is offline Member
    Join Date
    Jul 2012
    Location
    Norway
    Posts
    29
    Rep Power
    0

    Default Absolute positioning? I'm confused!

    Ok, I'm still a bit confused. In general, what is the best way of implementing a frame that contains various content boxes of different sizes, locations and on different layers of the frame (root pane versus whatever other z-axis panes), when I want each box to have an exact location (absolute positioning). I don't want it to be restricted to any predefined Layout with set content locations (top, center, bottom). I want to set my own number of fields in the window.

    I'm gonna read through all the threads in this section, but I thought I'd ask more specifically to absolute positioning. Here's an image of what I want, potentially:

    Absolute positioning? I'm confused!-frame.jpg


    The way I see it, there's 2 different (nested) sets of window hierarchies here:

    1. The interface hierachy, of which the worldpane (center box) is the bottom one and those smaller circles and squares are the top ones.
    2. A separate worldpane hierarchy (not seen here) where the game models/images are on top of eachother, but all are below the interface hierarchy.

    ====================

    My question is this: what methods do I need to look into and why? I'm also confused as to what really constitutes a JPanel. Is a JPanel just a rectangular field that may or may not be visible (with it's own background parameters) and may or may not have other items in it (JTextField etc)? And is it possible to assign a Z-position to a given pane (e.g. JPanel)?

    Do I just need to set a different layout for JPanel that support absolute positioning? What's that layout called? Or am I just focusing so much on the deeper learning part of something that I'm overlooking something that is right in front of me?

    Thanks in advance.
    Last edited by DrMadolite; 08-17-2012 at 04:34 AM.
    May the Newtonian physics be with you.

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

    Default Re: Absolute positioning? I'm confused!

    Quote Originally Posted by DrMadolite View Post
    Ok, I'm still a bit confused. In general, what is the best way of implementing a frame that contains various content boxes of different sizes, locations and on different layers of the frame (root pane versus whatever other z-axis panes), when I want each box to have an exact location (absolute positioning). I don't want it to be restricted to any predefined Layout with set content locations (top, center, bottom). I want to set my own number of fields in the window.
    You can still do all this by using the layout managers and easier too. I strongly urge you to go through the tutorial on this (Google will help you find it). You won't regret doing it. Also note that you can nest JPanels, each using its own layout to help make complex GUI's using simple layout managers.


    My question is this: what methods do I need to look into and why? I'm also confused as to what really constitutes a JPanel. Is a JPanel just a rectangular field that may or may not be visible (with it's own background parameters) and may or may not have other items in it (JTextField etc)? And is it possible to assign a Z-position to a given pane (e.g. JPanel)?
    Again, the tutorials will help explain what a JPanel is and what it isn't. It is a container like a JComponent but with different properties including its being opaque, its using the FlowLayout as its default layout manager.

    Do I just need to set a different layout for JPanel that support absolute positioning? What's that layout called? Or am I just focusing so much on the deeper learning part of something that I'm overlooking something that is right in front of me?
    absolute positioning is done by using null as the layout manager, but again, I've made *many* Swing GUI's, and find it much easier to make complex and flexible GUI's by using the layout managers to their full potential.

  3. #3
    DrMadolite is offline Member
    Join Date
    Jul 2012
    Location
    Norway
    Posts
    29
    Rep Power
    0

    Default Re: Absolute positioning? I'm confused!

    Quote Originally Posted by Fubarable View Post
    You can still do all this by using the layout managers and easier too. I strongly urge you to go through the tutorial on this (Google will help you find it). You won't regret doing it. Also note that you can nest JPanels, each using its own layout to help make complex GUI's using simple layout managers.
    I'm finding GridBagLayout interesting, maybe the restrictions I'm seeing is just me not knowing all its methods. I'll look more into it, and currently I'm reading up on the JRootPane and its various subpanes, just to get a sense of how it all works when JFrame and other main windows instantiate it (I know I don't need to instantiate it myself).

    Quote Originally Posted by Fubarable View Post
    absolute positioning is done by using null as the layout manager, but again, I've made *many* Swing GUI's, and find it much easier to make complex and flexible GUI's by using the layout managers to their full potential.
    Plus, I'm assuming that, if wanted, you can still use absolute positioning within a window that is called by a different window that uses a layout manager, because the parent window's layout does nothing with called window's layout, right?

    Also, it seems like I need to practice more using contentPane.
    May the Newtonian physics be with you.

Similar Threads

  1. Absolute beginner
    By duff18 in forum New To Java
    Replies: 15
    Last Post: 02-19-2011, 11:07 AM
  2. Replies: 2
    Last Post: 02-08-2010, 01:03 AM
  3. Positioning using setBounds
    By thayalan in forum AWT / Swing
    Replies: 4
    Last Post: 04-28-2009, 02:59 AM
  4. panel positioning
    By shwein in forum New To Java
    Replies: 4
    Last Post: 09-09-2008, 06:15 PM
  5. Specifying absolute path in web.xml
    By Felissa in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 07:56 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
  •