Results 1 to 7 of 7
  1. #1
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default Panel and Gui Question

    So as I'm exploring the wonderful world of swing and awt in my books I came to something not really covered by the book or in any article I've come across in Google that wasn't restricted. My book has always shown code that goes in a certain order for adding things to a frame. ie.

    Make Frame
    Set Frame Options
    Make Panel
    Make Components
    Add Components to Panel
    Add Panel to Frame

    However in some partial code where they are explaining how to set the layout manager of a panel they showed these steps in this order.

    Make Panel
    Make Components
    Add Panel to Frame
    Add Components to Panel

    My question is, as I assume the book is not incorrect, is there more or less a rather free flow of order in which you are to configure the end gui user interface? Also if anyone knows of a good article that explains this a little more deeply I would be much obliged. Unfortunately I'm on highly restricted internet so I have little hope for actually finding one.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Yeah there is a bit of leeway in what order things happen. The only thing that does matter is you should make a call to setVisible (and possibly pack) last or as close as. Otherwise things may not be displayed correctly

  3. #3
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Ok, but as long as everything else is added in the order I want them to be added into panels it doesn't matter if I add the panel before or after the frame. Got it.

    Thanks for clearing that up, it makes everything a little bit easier.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Be careful though. If you add things willy-nilly then your code will be hard to read. Try to organise it into logical sections as much as possible.

  5. #5
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Indeed, I wasn't planning on throwing code around just because I could. Modern artistic expression isn't so much appreciated in the code world I guess

    P.S. Did they remove the Mark this thread as solved from the forum options?
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Yeah apparently it got "lost" in the last upgrade.

  7. #7
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Oh, how inconvenient. Very well then.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

Similar Threads

  1. panel on a panel not visible
    By warchieflll in forum Advanced Java
    Replies: 2
    Last Post: 01-29-2011, 08:29 PM
  2. Add panel to parent panel
    By LovJava in forum AWT / Swing
    Replies: 10
    Last Post: 09-02-2010, 08:43 PM
  3. Panel in a panel?
    By pahiker in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2010, 11:42 AM
  4. Adding a panel to a panel
    By rclausing in forum New To Java
    Replies: 7
    Last Post: 02-02-2010, 05:56 AM
  5. add image on panel
    By samiksha.goel in forum AWT / Swing
    Replies: 4
    Last Post: 08-02-2008, 07:38 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
  •