Results 1 to 4 of 4
  1. #1
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default JPanel not showing when painting on JFrame

    Hello,

    My program is painting directly to a JFrame that contains a JPanel. The program also sets the JPanel to be somewhat translucent.

    The program is not displaying the JPanel. Is there any reason why this would be happening?

    Stephen

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

    Default Re: JPanel not showing when painting on JFrame

    Quote Originally Posted by shall View Post
    Hello,

    My program is painting directly to a JFrame that contains a JPanel. The program also sets the JPanel to be somewhat translucent.

    The program is not displaying the JPanel. Is there any reason why this would be happening?
    Possibly because you're painting directly to a JFrame. Never do that.

  3. #3
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: JPanel not showing when painting on JFrame

    Ok. What is the right way to do it?

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

    Default Re: JPanel not showing when painting on JFrame

    Draw in the paintComponent(...) method of a JPanel or JComponent, and then add this to the JFrame. Check out the Swing graphics tutorials for more details.

Similar Threads

  1. painting to a JPanel in a JFrame
    By Parkournerd in forum AWT / Swing
    Replies: 1
    Last Post: 01-16-2012, 10:24 PM
  2. Problem painting on JPanel
    By Boatski in forum AWT / Swing
    Replies: 0
    Last Post: 12-01-2010, 05:36 AM
  3. JPanel not showing up in JFrame
    By rlindsey in forum AWT / Swing
    Replies: 2
    Last Post: 06-25-2010, 08:21 AM
  4. JPanel not always painting everything
    By ekted in forum AWT / Swing
    Replies: 0
    Last Post: 11-26-2009, 12:24 PM
  5. Jpanel painting problem
    By kcakir in forum AWT / Swing
    Replies: 3
    Last Post: 04-15-2009, 11:21 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
  •