Setting the image size within a JFrame!

This is the code i have implemented

import javax.swing.*;

import java.awt.*;

class SampleJFrameextends JFrame

{

JLabel l1;

ImageIcon image;

SampleJFrame()

{

image=new ImageIcon("G:/java files1/images/aa.jpg");

l1=new JLabel("DEDICATION",image,JLabel.RIGHT);

l1.setSize(100,100);

//this.setLayout(new FlowLayout(FlowLayout.RIGHT));

this.add(l1);

}

}

publicclass JFrame2

{

publicstaticvoid main(String args[])

{

SampleJFrame samplejframe=new SampleJFrame();

samplejframe.setTitle("FRAMES WITH JLABELS WITH IMAGEICON");

samplejframe.setSize(400,400);

samplejframe.setVisible(true);

}

}

When i run this the image occupies the entire JFrame.I want to resize it to a width of around 100,80 pixels.How can i do it?

I know when i draw a image without linking to a label i can use drawImage of Graphics class to set the size of the image.But in this case i am linking the image to the JLabel and it's occupying the entire screen and the text with the JLabel is thrown somewhere out.

[1906 byte] By [qUesT_foR_knOwLeDgea] at [2007-11-26 15:31:06]
# 1
There's a lot of basic information in this thread: http://forum.java.sun.com/thread.jspa?threadID=522483
DrLaszloJamfa at 2007-7-8 21:47:55 > top of Java-index,Java Essentials,New To Java...
# 2

Read it.Got a lot of info from that.But the trouble with mine is that i am linking the image to the JLabel and thats why i am unable to set its size because the image will be added to the JPanel when i add the JLabel to it?If i was directly printing the image i would have rather used Graphics.drawImage( ) where i can manually specify the width.

qUesT_foR_knOwLeDgea at 2007-7-8 21:47:55 > top of Java-index,Java Essentials,New To Java...
# 3

You can still use JLabel + ImageIcon:

BufferedImage originalImage = ImageIO.read(theUrl);

BufferedImage resizedImage = resizingSubroutine(originalImage, theScalingFactor);

Icon icon = new ImageIcon(resizedImage);

JLabel label = new JLabel(icon);

...

DrLaszloJamfa at 2007-7-8 21:47:55 > top of Java-index,Java Essentials,New To Java...
# 4
Thanks lazlo.Will check it out.
qUesT_foR_knOwLeDgea at 2007-7-8 21:47:55 > top of Java-index,Java Essentials,New To Java...