Results 1 to 5 of 5
  1. #1
    wired-in=p is offline Member
    Join Date
    Jul 2011
    Posts
    38
    Rep Power
    0

    Default Rendering graphics on JPanel

    I have a JPanel that is half covered by a Jtextarea. In addition, i tried to display graphics on the panel as well. I assume that I cannot display graphics on top of the Jtextarea, or any other component for that matter, and instead I would need to use a JLayer and LayerUI. However, i tried to display my graphics below the jtextarea, where the panel was empty, and it wouldn't work. Does this mean that to display graphics on a panel that contains a component, a Jlayer must be used?

  2. #2
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default Re: Rendering graphics on JPanel

    Make two separate JPanels and place them in each half of your Frame. And use a paintComponent on the second JPanel.

  3. #3
    wired-in=p is offline Member
    Join Date
    Jul 2011
    Posts
    38
    Rep Power
    0

    Default Re: Rendering graphics on JPanel

    I've done that... if i don't add the panel with the text box, my graphics are displayed, if i have both panels, then the graphics won't be displayed.

  4. #4
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default Re: Rendering graphics on JPanel

    It also depends on the type of Layout you are using. In this case, you can use GridLayout and set its column to 2.
    See: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)

  5. #5
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default Re: Rendering graphics on JPanel

    Make sure your JPanels are placed in different places so both can be displayed and one is not completely overlapping the other.

Similar Threads

  1. Replies: 11
    Last Post: 03-09-2011, 09:18 AM
  2. JPanel and graphics
    By nevermiind in forum AWT / Swing
    Replies: 5
    Last Post: 03-04-2011, 02:21 PM
  3. Can't display my graphics in a JPanel
    By handro1104 in forum AWT / Swing
    Replies: 2
    Last Post: 02-14-2011, 04:40 PM
  4. Jpanel and displaying graphics
    By jdsflash in forum New To Java
    Replies: 6
    Last Post: 11-21-2009, 02:14 AM
  5. Newbie need help on JPanel graphics
    By junpogi in forum AWT / Swing
    Replies: 7
    Last Post: 10-21-2008, 08:44 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
  •