Results 1 to 5 of 5
  1. #1
    dinhtrieu08t4 is offline Member
    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Default Help me displays an image

    Hello everyone,
    I have a Java exercise basic. But I can't solve it. Can you hep me?
    It is:" Develop a Frame that displays an image that its text is: “press here to know what I
    think”. Each trial to click on the image will move it to another location."
    Thank you very much.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Help me displays an image

    What have you tried? Where are you having problems? The following link might help
    Java Programming Forums - How to Program (stuck on homework? READ THIS BEFORE POSTING)

  3. #3
    Join Date
    Aug 2011
    Location
    Pretoria, South Africa
    Posts
    27
    Blog Entries
    3
    Rep Power
    0

    Default Re: Help me displays an image

    I have to agree with doWhile. Forums is used to discus problems, not to do homework for other ppl. I can help you so far by only saying you will need a JFrame, set the layout to null, add a JPanel where you define the paintComponent method and paint the image on it and add a mouseClicked event to the panel, then with every click you can can move the panel inside the JForm to a new random location with the setLocation method.

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Help me displays an image

    set the layout to null, add a JPanel where you define the paintComponent method and paint the image on it and add a mouseClicked event to the panel, then with every click you can can move the panel inside the JForm to a new random location with the setLocation method.
    FWIW, I would discourage using a null layout and painting the image using paintComponent might be overkill when there is both an ImageIcon and JLabel class.

  5. #5
    Join Date
    Aug 2011
    Location
    Pretoria, South Africa
    Posts
    27
    Blog Entries
    3
    Rep Power
    0

    Default Re: Help me displays an image

    o yeah, that is also true... forgot about those. So use to working with paint on JPanels and JWindows with png images to get a desired effects I want.

Similar Threads

  1. Why does this code displays an error?
    By Skipito in forum New To Java
    Replies: 2
    Last Post: 07-06-2011, 03:10 AM
  2. button displays image
    By hopelessnoob in forum AWT / Swing
    Replies: 2
    Last Post: 03-12-2011, 03:44 PM
  3. Touch Displays
    By Ciwan in forum New To Java
    Replies: 4
    Last Post: 10-21-2010, 09:47 AM
  4. Web site Image Displays based on day of the week?
    By foxdog175 in forum New To Java
    Replies: 6
    Last Post: 04-15-2009, 12:21 AM
  5. Problem when displays in the terminal
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 02:14 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
  •