Moving a jpg image on top of another jpg image

I am currently doing a game board project and I need code to move an image that is on top of another image. I have the board image up but I need to put the other image on top of it and move it. Please someone with code to drag and drop help me. Thanks Anne

Try this code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Iover extends JFrame
     Mpan   pan = new Mpan();
     JLabel lbl;
public Iover() 
     addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     setBounds(10,10,520,350);
     getContentPane().setLayout(new BorderLayout());
     getContentPane().add(pan,BorderLayout.CENTER);      
     pan.setLayout(null);
     lbl = new JLabel(new ImageIcon("game1.gif"));
     lbl.setBounds(100,100,100,100);
     pan.add(lbl);
     setVisible(true);
     lbl.addMouseMotionListener(new MouseMotionAdapter()          
     {     public void mouseDragged(MouseEvent m)
               lbl.setLocation(lbl.getX()+m.getX(),lbl.getY()+m.getY());
public class Mpan extends JPanel
public Mpan()
public void xpaint(Graphics g)
     g.setColor(Color.pink);
     g.fillRect(0,0,getWidth(),getHeight());
     paintComponents(g);
public static void main (String[] args) 
     new Iover();
Noah

Similar Messages

  • HT1933 Moved ITunes from one lap top to another, and some audiobooks were lost??

    Moved iTunes library from one lap top to another, and some audiobooks were lost!

    Sorry to hear that.
    Do you have a question?
    Copy the audiobooks from the old computer, or your backup copy of your old computer to the new one.

  • Drawing image so that it appears on top of another

    Alright, this question isn't as straight forward as it may seem. Yes, I want to draw an image so that it appears on top of another drawn image, but the image I am trying to draw is being drawn in another thread like so:
    public class myApplet extends Applet implements Runnable
      public Graphics g;
      public Thread myThread;
      public void init()
        myThread = new Thread(this);
        myThread.start();
      public void paint()
         super.paint(g);
         //Assume that I loaded in the images properly
         g.drawImage(image1, 0, 0, null); //Assume image1 is a 50 px X 50 px image
      public void run()
         g.drawImage(image2, 0, 0, null); //Assume image2 is a 20 px X 20 px image
    }This also happens if I try to do "g.fillRect();". The 50 X 50 image appears on top of the 20 x 20 image. Does anyone know a way that I can tell the program to draw the image in the thread AFTER the image in the paint method (I know I should be using paintComponent, but this is a sample program. Please don't get too picky about it. I typed it up simply for this post and I wanted to make it simple).
    The reason I'm drawing it in the paint method is because I am making an image move along a set of points. The points are formulated inside the run() method. If I draw it inside of the paint() method it skips points.
    Any help would be GREAT. Thank you.
    Edited by: dustty1818 on Apr 11, 2009 9:05 AM

    dustty1818 wrote:
    public class myApplet extends Applet implements Runnable
    public Graphics g;
    public void run()
    g.drawImage(image2, 0, 0, null); //Assume image2 is a 20 px X 20 px image
    }Edited by: dustty1818 on Apr 11, 2009 9:05 AMDusty,
    There are several serious (fatal) flaws with your design. The biggest is that you should NEVER hold
    on to a Graphics object. If anything you should be calling dispose at the end of the paint method.
    It appears that you are accidentally trying to use a technique called "active rendering".
    You can do active rendering in Java but it would look nothing like what you are doing (and is much
    more advanced). You must resolve to keep all drawing in (or preferably called from) the paint method.
    Have your run() method call repaint() and have your paint() method have all the information it
    needs to render the scene.
    Also, and this is comparatively minor, extend JApplet.
    example:
    import java.awt.*;
    import javax.swing.*;
    public class SceneRenderer extends JApplet implements Runnable{
         Point pt1 = new Point(0, 0);
         Point pt2 = new Point(0, 0);
         public void init(){
              Thread animationThread = new Thread(this);
              animationThread.start();
         public void paint(Graphics g){
              super.paint(g);
              g.setColor(Color.RED);
              g.fillRect(pt1.x, pt1.y, 50, 50);
              g.setColor(Color.BLUE);
              g.fillRect(pt2.x, pt2.y, 20, 20);
         public void run(){
              while(true){
                   pt1.x += 1;
                   pt2.x += 1;
                   repaint();
                   try{
                        Thread.sleep(60);
                   } catch(Exception e){}
    }

  • Cant put image on top of another image

    Hi,
    I'm using keynote 09 with the 'Blueprint' theme. I'm attempting to edit the master slides by putting a company logo in the corner of each slide. This works fine on slides without images, but on slides with images, keynote will not let me put my logo over the image placeholder. The placeholder image always blocks my logo, even when I choose 'Send backward' on the place holder.
    Is there a way around this?
    thanks

    Sorry, I was typing fast.
    The problem is that you cannot put images above media placeholders on master slides. One suggestion was to make my image (my logo comprised mostly of white text) a media placeholder as well, therefore I could edit the master slide and layer my new media placeholder (logo) above the default-already-existing placeholder (some architectural image in the blueprint theme).
    This works but has an additional problem.
    Since my logo is white text, I wanted for it to stand out from the picture beneath it. As I sometimes do, I thought I should place my white-text-logo on top of a small black rounded rectangle with transparency (like a cartouche).
    I like to do that because it makes my logo legible, while still showing the picture through the transparency. INdeed, this is easy to do if you are only dealing with pictures and shapes (and not the magical placeholder versions of them)
    You can make the shape a text placeholder, and you can make the image (logo) a media placeholder, but you can't group the two together as a unit. And if you group them first, then you cannot make your group (shape+image-logo) a placeholder at all, so you then cannot layer it on top of the default image place holders.
    I was saying that I'd have to open my logo in photoshop and put it on top of a 'cartouche' and then import that modified image, and THEN make it a media placeholder.
    But obviously it would be easier if keynote just let us properly layer elements as you would expect it to work.
    I mean, setting images aside, why can't I create a shape and put it in front of a media placeholder without making the shape a text placeholder?
    Of course I can edit my logo and add dropshadow or glow to make it stand out, but even then, I would need to make it a placeholder before keynote would let me layer on top of another placeholder. And if I'm going through the trouble of using photoshop to add shadows or glows, I might as well just put the image on top of a cartouche as originally desired.

  • Text becomes overset when moved on top of another object

    I'm trying to figure out why everytime I move a text box on top of another object the text suddenly becomes overset and disappears.  If I move it off the object or out of the spread entirely, the text comes back and appears normal.  I've tried placing the file, copy and pasting the file, copy and pasting the selected text, moving the text box into a separate layer, checking the ordering to ensure the text box is on top, but nothing seems to work.  Any thoughts on why this is happening?

    OGC Management wrote:
    ... if I checked the invert box it corrected the problem! 
    your going to chase your tail with that "solution".
    Select all (ctrl+a)(cmd+a) and set Text Wrap to none as shown.
    The item could be on a master page or a locked layer, but  you indicate you were able to modify the wrap attributes...

  • White Balance Selector Disappears when moved across the image

    Hi
    I am using LR 4.4 on an iMac.
    Does anyone know why the White Balance Selector tool would disappear when moved across an image?
    it seems to change to a vertical line with an arror top and bottom.
    The areas of the image on which it disappears seem to be consistent, in other words, it disappears on the same portion of the image eveytime.
    UPDATE: Since posting the above a few minutes ago I've noticed that my cursor is behaving eractically. For example, on a different image to the one used above, in the library module using the Loupe the cursor changes from a magnifying glass to an arrow pointing to the right.  It does this on the same part of the image every time.
    Thank you for your help
    Regards
    Message was edited by: iwaddo

    Weird cursor problems are a FEATURE of the APPLE os.
    There are complaints on the APPLE os system website since 2005.
    The last time I checked there were 30 pages of discussions about this on the apple site
    https://discussions.apple.com/community/mac_os/os_x_mountain_lion.
    I don't think APPLE has a clue as to how to fix this. It is seen in many apps, photoshop most commonly, lightroom,textedit,exxcel, and others.
    Pray that something happens in soon to be released 10.8.4.
    vince

  • After OS X update moving 1:1 images results in low resolution and a long delay to snap into high res

    After the OS X 10.8.5 update on my current generation 27' iMac moving 1:1 images results in very low resolution for those areas I am moving to with as long as a two second delay before the image snaps back into full resolution. Not only that but when it snaps back into full resolution you see a shift in alignment and a snapping into place with the nearby area that was already in full resolution. This is awful and is occuring with Lightroom 5 and 5.2. Has anyone experienced this?
    My iMacs specs are the current generation 27" iMac, i7 3.4 Ghz, 32GB RAM, and the NVIDIA GeForce GTX 680MX 2GB running OS X 10.8.5.
    I did not have this issue with OS X 10.8.3.

    I have noticed something similar on my Win7x64 system, but am not able to reliably reproduce it. It seems, for me at least, to be a combination of +Clarity and Lens Profile Correction which will always trigger an observable screen redraw when moving from segment to segment in 1:1 view mode. The variable is the delay.....most often it's a fleeting effect, but occasionally there's a more obvious delay in redrawing the image display. I suspect the more obvious delay is, in addition to the +Clarity and Lens Correction, some internal resource utilisation over a longer Lightroom session....certainly every time I've encountered it a Lightroom restart has cleared it up.
    Don't know it that helps, or gives you any pointers to reducing the impact. Because of another "issue" with Lens Corrections (when it's applied, Spot Removal work gets slower), I tend to apply it last of all when editing pictures....so that also helps avoid this 1:1 screen redraw problem.

  • Zooming, scrolling and moving in large images

    I'd like to create a document viewer that works like Google Maps or Safari. Basically the "image" of the document is so big that I only want to load parts of it when the user actually goes over to that part of it.
    How can I enable zooming, scrolling and moving in "large" images like that?
    I looked for a tutorial or sample code, but I wasn't able to find anything.
    Any help would be appreciated,
    -Chris.

    I have 4 Gbyte of RAM. I tried to close every applications but the problem remains. You are right about Web Browser problems but unfortunately my problem is related with Finder windows too. I have 800 Mbyte of free RAM.
    Another fact I can say to you is that when I move Finder window (or other windows as I wrote before) the area outside the border of the window is repainted not well with puzzle effect. I think the problem is related to desktop refresh and repaint. It seems that graphic acceleration doesn't work for some window!!!!

  • I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library.

    I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library. 
    I don't see anything in Help that shows when you already have transfered all the files over.  Why would it want to erase and sync when I already have all the music folder copied over?  I didn't have an issue when I had another technician copy from one laptop to another.  Home sharing is also on but not being recognized.

    I suspect you only migrated the media folder instead of the complete working library. Either review the transfer process and copy over the entire iTunes folder from your old profile's music folder or see Recovering your iTunes library from your iPod or iOS device.
    tt2

  • Can we create materialized view on the top of another materialized view.

    Hi ,
    can we create materialized view on the top of another materialized view.
    Thanks
    Naveen

    Welcome , Just remember is not good apporch to do that since performance when MV refresh
    Please mark this thread as answered .

  • I have over 200 hours of HD video on 5 different TB Thunderbolt GRaid hard drives. I need to reorganize my projects, moving large files from one drive to another. Advice?

    I have over 200 hours of HD video on 5 different TB Thunderbolt GRaid hard drives. I need to reorganize my projects, moving large files from one drive to another. Advice?

    Do some testing to get your method working right with some less than important footage.
    Copy/paste files where you want then.
    Use the FCE Reconnect feature to tell FCE where the newly copied files reside.
    Make sure the new location and files are working as expected with your Projects.
    Delete the original files if no longer required.
    Al

  • Moving multiple queries from one category to another in QM

    Hi All,
    Is there is any way of moving multiple queries from one category to another in the query manager?
    Or is the only way of doing it by saving each one individually into a different category.
    Any ideas ?
    Regards,
    Rakesh N

    Hi Rakesh,
    The query manager has limited function compare with normal file management applications. Under current design, you have to do this one by one. You just need to make sure move the smaller amount of queries to large category. Category name can be changed easily.
    Thanks,
    Gordon

  • How can I copy a part of the picture and paste this piece on top of another part of the same picture? ta

    How can I copy a part of the picture and paste this piece on top of another part of the same picture? ta

    select the section you want to copy (marquee tool or lasso tool) and either go to edit copy or use control c create a new layer in layers (top menu bar) or Control shift N and paste using control V;  or edit > paste.

  • Moving photos from one hard disk to another but not loosing the editing history on the photo

    Hello,
    I have one hard disk filling up with photos, so I have purchased a secondary hard disk to expand my storage.  I would like to move my shoots from 2010 to that new hard disk, but I don't want to loose all of the edits saved on them in LR3.  I have experimented with moving non-important images that have edits on them, then re-importing them.  Unfortunately, LR3 does not preserve that history.  Is this possible?
    Thanks!
    Adam Pendleton

    Adam, reimporting is not the way to achieve what you want.
    There are several ways to achieve your goal though:
    1. Move the files with your OS from one drive to the other - best to move one folder if they are all in one (2010) and then relink in LR by right clicking the folder in the Library Folder panel and choosing "Update Folder Location".
    2. Use Lightroom to move the folders in the Library by dragging and dropping them - this can be done one folder at a time only.

  • What is the impact on an Exchange server when moving FSMO role and schema master into another DC?

    What is the impact on an Exchange server when moving FSMO role and schema master into another DC? What do we have to do on exchange after performing a such task?
    I had 1 DC (Windows server 2008 R2), 1 Exchange 2010 SP3. I install a new DC (Windows server 2008 R2). I then move all the FSMO role including the schema master role into the NEW DC. I check to be sure that the new DC is a GC as well.
    I shutdown the old DC and my Exchange server was not working properly and specially Exchange Management Shell. It start working again after I turn up the older DC.
    I am wondering why Exchange did not recognize the new DC, even after moving all the roles on it.
    I am looking to hearing from you guys.
    Thanks a lot

    if you only have 1 DC, you might need to cycle the AD Topology service after shutting the one down.
    Also, take a look in the windows logs, there should be an event where Exchange goes to discover Domain Controllers, make sure both are listed there.  You can probably force that by cycling AD topology (this will take all services down so be careful
    when you do it)
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread

Maybe you are looking for

  • Using Front Row to view photos stored on a network drive.

    Good evening. I am setting up all my files on a network drive. I've got Front Row "seeing" my movies on the drive and my music too. What I'm looking to do is have it "see" my photos. Here is what I would like to do if possible: I have my photos on th

  • Update the authorization object value for more than 1000 role

    I need to remove one of the activity value (06) from authorization object S_SCD0. I do a search and found out that there are more than 1000 roles which having the activity value = 06 for authorization object S_SCD0. However, I don't think I can creat

  • Need Help on Case Statement

    Hi all I'm stuck on scenario. I have query something like this Select  HIRE_DATE,             ENAME,         ( case when EMP_NO=10 then           case when exist                select ENAME from                 EMP_DTL                where EMP_DTL.EM

  • I phone 4 gets no service anywhere... why???

    I Upgraded the i phone 4 to the ios 5 and i get NO service anywhere even when im at home im connected to wi fi and every 1 else has service but me..... why is that i had the i phone 3g before and it worked great!! but ever since i upgraded and took m

  • No privacy settings to control incoming and outgoing calls

    Is it possible to restrict incoming calls on the Droid Razr Maxx?  With other Motorola phones (Droid X) it's easy to restrict incoming (and outgoing) calls to the address book only.  .just can't find one.....thank you