Results 1 to 3 of 3
  1. #1
    NotTooOld is offline Hostage
    Join Date
    Apr 2013
    Location
    China
    Posts
    128
    Rep Power
    0

    Default Design view... buggy??

    Hey all, I'm working on my first JFrame project that uses CardLayout. I have methods I use to build each JPanel "card" before adding it to the "holder" JPanel. Problem is, now when I go to Design view, the only components in the Components View is the first card in the stack. I even tried changing the order that they get added to the stack, but I can still only see the first one. I can't even select any component that is not part of this JPanel. (can't see em) How can I restore the view so I can visually work on other JPanels??

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Design view... buggy??

    By Design view, I presume you mean a GUI builder? You mention this is your first JFrame project, so if you are referring to a GUI builder, I'd recommend ditching it. It can often make building, adapting, and reading code that much more difficult for beginners. The alternative: spend some time with the java Tutorials
    How to Use CardLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)
    If you aren't referring to a GUI builder, then I'd recommending defining what you mean by 'Design view'

  3. #3
    NotTooOld is offline Hostage
    Join Date
    Apr 2013
    Location
    China
    Posts
    128
    Rep Power
    0

    Default Re: Design view... buggy??

    Quote Originally Posted by doWhile View Post
    By Design view, I presume you mean a GUI builder? You mention this is your first JFrame project, so if you are referring to a GUI builder, I'd recommend ditching it. It can often make building, adapting, and reading code that much more difficult for beginners. The alternative: spend some time with the java Tutorials
    How to Use CardLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)
    If you aren't referring to a GUI builder, then I'd recommending defining what you mean by 'Design view'
    I am indeed referring to WindowBuilder, included with my download of Eclipse. I am sorry if my statement wasn't clear. This is not my first JFrame, nor the first time I've used WindowBuilder, but the first time I have tried to incorporate CardLayout. As my project grew, it became unmanageable to have everythingin one huge method. I decided to move the construction of the individual JPanels (cards) into methods of their own. When I did this, the Component View, within WindowBuilder, changed and was only displaying a single JPanel. (Nothing above it in the hierarchy, such as the JPanel with the Layout CardLayout, or the getContentPane or JMenuBar)

    The good news is I simply (temporarily) added
    Java Code:
     JPanel cardThree = new JPanel();
    deck.add(cardThree);
    to the drawGUI method that is called in the main method, and "PRESTO!" I can see the entire hierarchy again. Lesson learned about WindowBuilder: Do not move a component's instantiation from the method called by the main method, until after it is complete. If you do, expect WindowBuilder to lose track of what is actually in the project. Oddly enough, even when everything disappeared, there were still lines adding the JPanel "deck" and my JMenuBar to the getContentPane, but they disappeared too. (By disappeared I mean they did not appear in the Component View within WindowBuilder's Design View.)

    Problem handled! If not solved, at least worked around.
    Last edited by NotTooOld; 04-21-2013 at 07:31 AM.

Similar Threads

  1. design view not available?
    By anarelle in forum NetBeans
    Replies: 3
    Last Post: 07-06-2011, 03:43 PM
  2. How to see web pages in design view
    By shantanu88d in forum NetBeans
    Replies: 0
    Last Post: 03-08-2011, 05:59 PM
  3. Netbeans - Design view
    By efebatistaarda in forum New To Java
    Replies: 1
    Last Post: 02-16-2011, 07:17 AM
  4. Can't see my JFrame in Design View
    By byubi in forum NetBeans
    Replies: 0
    Last Post: 02-08-2011, 08:02 AM
  5. How enter this mode-gui/design-view/code-view
    By lse123 in forum NetBeans
    Replies: 0
    Last Post: 02-28-2010, 09:09 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
  •