views:

24

answers:

1

I am trying to get my program to display an image after it is dragged over, but I dont really have a good idea of how to do this.

Example: There is an image on your desktop, photo.jpg . You would take that, drag it over into a java JFrame, and the contents of that image (the photo iteself) would display.

From there I would like to be able to play with the size ability of the photo, but first step first, I dont know how to approach getting it to display in the JFrame. Any help would be greatly appreciated.

+2  A: 

Once you have the image (I didn't think you were asking about the drag-and-drop feature, if that was the part you were asking about, sorry.), you can either push the image into an ImageIcon and display it in a JLabel as described here

Or you can mess around with using Graphics#drawImage methods in paintComponent to draw Images. Something along the lines of (as a very basic example):

public void paintComponent(Graphics page)
{
    super.paintComponent(page);
    page.drawImage(img, 0, 0, null);
}

I give a more detailed example here.

Reese Moore