Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How can I repaint() an entire JPanel, except for a specific area?

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I repaint() an entire JPanel, except for a specific area?

    How can I repaint() an entire JPanel, **except** for a large group of pixels that aren't necesserily organized in a rectangle? (Like a big group of pixels forming a scribbled line)?
    Thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: How can I repaint() an entire JPanel, except for a specific area?

    Here's an idea: Create a BufferedImage and make the pixels fully transparent where you want the underneath image to show through and draw on the rest as desired. Draw the underneath image and then draw the custom BI over the top.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How can I repaint() an entire JPanel, except for a specific area?

    Excellent idea, Norm.

    I haven't looked at it for some time, but I also know there's a way to "watermark" the drawing area. I believe there are actually layers or separate panes to the JComponent's drawing surface that can be drawn on separately so that the permanent image can be drawn on one pane atop or behind another that is subject to change by the normal means. Look into this idea by searching "jcomponent drawing panes", "jpanel watermark", or similar.

Similar Threads

  1. [SOLVED] JPanel and JText area keep resizing even though I'm telling it not to.
    By GoodbyeWorld in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 24th, 2013, 04:32 AM
  2. Replies: 5
    Last Post: August 10th, 2013, 03:21 PM
  3. Repaint immediately JPanel (with PDFRenderer)
    By brajan1984 in forum AWT / Java Swing
    Replies: 2
    Last Post: January 10th, 2013, 07:10 AM
  4. WHY AM I HAVING TO PUT THE ENTIRE FILE PATH?!?!
    By CameronHussey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 7th, 2011, 05:32 AM
  5. Repaint doesn't repaint?
    By PotataChipz in forum AWT / Java Swing
    Replies: 6
    Last Post: January 18th, 2010, 09:56 PM

Tags for this Thread