Results 1 to 3 of 3
  1. #1
    marodia is offline Member
    Join Date
    Aug 2009
    Posts
    9
    Rep Power
    0

    Post how to resize an image

    hello friends.........
    i am in a fix .i have added a image to my jpanel but it's not occupying the entire
    panel...is there a way to resize the image so that it occupies the total panel.

    Also can can you suggest how can we write text on images

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You probably draw your image via Graphics#drawImage(....) within your paintComponent method. Check out the Graphics API for the different overloads for that method. You may find one that suits your purposes well. To draw text, in the same paintComponent overridden method, call drawString on your Graphics object. To draw on the image, draw the string after you draw the image.

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    I'm no expert on this subject, but I have used Image.getScaledInstance to rescale an image. I have found that paint() methods get called a lot more often than I originally expected, and creating and saving a scaled image and using that until the panel size changes may produce a noticeable performance improvement...

Similar Threads

  1. Image Resize
    By jithan in forum New To Java
    Replies: 4
    Last Post: 11-07-2008, 10:26 AM
  2. Window resize icon...
    By pele in forum SWT / JFace
    Replies: 3
    Last Post: 06-09-2008, 09:31 AM
  3. resize tabs in jtabbedpane
    By osval in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 04:02 AM
  4. Resize frame
    By lenny in forum AWT / Swing
    Replies: 1
    Last Post: 07-30-2007, 12:18 AM
  5. Help with JTextArea, resize windows
    By paul in forum AWT / Swing
    Replies: 1
    Last Post: 07-16-2007, 05:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •