Results 1 to 4 of 4
  1. #1
    AvivC is offline Member
    Join Date
    Dec 2013
    Posts
    26
    Rep Power
    0

    Default JPanel-type class doesn't apear on the JFrame?

    I created a class named Surface the inherites from JPanel. This class draws a General Path inside it's paintComponent(). I tried adding it to a JFrame and it doesn't get displayed.

    Then I was advised to give the Surface instance a preferredSize, and it now displays correctly.

    My question is: Is the default for JPanel-type objects that only have a GeneralPath in their paintComponent() (no rectangles and other shapes), to be invisible until you explicitly set their preferred size?

    Thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: JPanel-type class doesn't apear on the JFrame?

    be invisible until you explicitly set their preferred size?
    Print the components size to see how big it is. It could be very small, but not invisible.
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JPanel-type class doesn't apear on the JFrame?


  4. #4
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: JPanel-type class doesn't apear on the JFrame?

    Depending on the layout manager, if you had any components over top of the JPanel and you didn't set the preferred size, it could cover it up.

Similar Threads

  1. Replies: 1
    Last Post: 12-25-2013, 02:51 PM
  2. Replies: 3
    Last Post: 12-08-2013, 09:28 PM
  3. Wild errors apear!
    By andreglud in forum Android
    Replies: 4
    Last Post: 11-18-2013, 11:59 AM
  4. JTextField on JPanel-class within JFrame-class
    By floris in forum AWT / Swing
    Replies: 5
    Last Post: 06-25-2012, 12:54 PM
  5. JPanel Listener doesn't work in a JFrame...
    By jiapei100 in forum AWT / Swing
    Replies: 2
    Last Post: 11-18-2010, 02:03 PM

Tags for this Thread

Posting Permissions

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