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 5 of 5

Thread: Image Resizing

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Image Resizing

    How can i re-size big images to fit small boxes?


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,104
    Thanks
    169
    Thanked 780 Times in 726 Posts
    Blog Entries
    5

    Default Re: Image Resizing

    See Lesson: Working with Images (The Java™ Tutorials > 2D Graphics) The Image class has a getScaledInstance method.

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Image Resizing

    Doesn't seem to help. Here is the code
    Image pic;
    public Screen(){
          pic = new ImageIcon("H://Workspace/Test/res/ball.jpg").getImage();
    }
    public void paint(Graphics g){
          pic = pic.getScaledInstance(290, 215, Image.SCALE_DEFAULT);
          g.drawImage(pic, 0, 0, null);
    }
    Last edited by usama8800; June 30th, 2012 at 12:30 PM.

  4. #4
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,104
    Thanks
    169
    Thanked 780 Times in 726 Posts
    Blog Entries
    5

    Default Re: Image Resizing

    Doesn't seem to help.
    You'll have to be more precise than that. Exceptions? Compile time errors? Post an SSCCE that shows the problem

  5. #5

    Default Re: Image Resizing

    There are some good examples regarding image resizing here and there.

Similar Threads

  1. Resizing on mouse movement
    By java_novice in forum Java Theory & Questions
    Replies: 9
    Last Post: February 3rd, 2012, 06:53 AM
  2. [SOLVED] Positioning/Resizing JList Help
    By KILL3RTACO in forum AWT / Java Swing
    Replies: 2
    Last Post: October 3rd, 2011, 01:00 PM
  3. [SOLVED] jsplipane and resizing
    By dabdi in forum Java Theory & Questions
    Replies: 9
    Last Post: June 7th, 2011, 12:10 PM
  4. Resizing JPanels in JScrollPanes
    By aussiemcgr in forum AWT / Java Swing
    Replies: 4
    Last Post: November 29th, 2010, 01:13 PM
  5. dynamically resizing 2d array
    By Flamespewer in forum Collections and Generics
    Replies: 2
    Last Post: March 2nd, 2010, 10:10 AM