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: Graphics Drawing Images/Rectangle Detecting/Deleting

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    10
    My Mood
    Angelic
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Graphics Drawing Images/Rectangle Detecting/Deleting

    Hello!

    I got serveral questions about Graphics in Java.

    • Is it possible to detect Drawn Images/Rectangles without knowing the x & y positions
    • Is it possible remove recangles? I know it's possible via "g.clearRect" but then at the place where the rectangle was is a black recangle now probaly because i work with a transparent background with a wood pattern.
    • Same question about but then with images no clearImage function found.
    • So above is the option about removing but isn't it possible to replace an drawn image with another one? I tried to draw another image on a certain x & y location but it just draws over it.
    • Another option (maybe, just brainstorming atm) it is possible of keeping track of positons where you draw something what if you make a seperate array with the places where the second image must come is it then possible to remove everything that Graphics has drawn (in a clean way so there are not black holes). And then just redraw everything from those arrays?



    Kind regards.

    PS: Sorry for bad english, was in a terrible rush when I typed this.


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

    Default Re: Graphics Drawing Images/Rectangle Detecting/Deleting

    Depending on the contrasting of the colors you might be able to scan an image and find a rectangle.
    I tried to draw another image on a certain x & y location but it just draws over it.
    Yes it would.
    There are some methods in Graphics2D that might be of interest to you for drawing.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    10
    My Mood
    Angelic
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Graphics Drawing Images/Rectangle Detecting/Deleting

    Quote Originally Posted by Norm View Post
    Depending on the contrasting of the colors you might be able to scan an image and find a rectangle.

    Yes it would.
    There are some methods in Graphics2D that might be of interest to you for drawing.
    I can only use Graphics in JavaTV :/

Similar Threads

  1. Drawing images with different angles
    By gargamel7 in forum AWT / Java Swing
    Replies: 24
    Last Post: September 13th, 2011, 06:04 AM
  2. [SOLVED] Java Graphics: Drawing one object into another
    By zaxahmed in forum Object Oriented Programming
    Replies: 5
    Last Post: August 22nd, 2011, 08:06 AM
  3. Drawing 2 images of a the same Sprite
    By risen375 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 15th, 2011, 10:25 AM
  4. Images (read/write, drawing)
    By helloworld922 in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 29th, 2010, 11:32 AM
  5. keeping an drawing centered in Graphics
    By dvsumosize in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 27th, 2010, 11:26 PM