resize image with the change in size of jpanel..

resize image with the change in size of jpanel..

View Answers

July 31, 2008 at 7:23 PM

Hi friend,


import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

public class ResizeImage extends JFrame{
JScrollPane scrollPane;
ImageIcon icon;
public ResizeImage(){
icon = new ImageIcon("cat.gif");
JPanel panel = new JPanel(){
public void paintComponent(Graphics g) {

Dimension d = getSize();
g.drawImage(icon.getImage(), 0, 0, d.width, d.height, null);
}
};
JButton button = new JButton("Rose");
panel.add( button );
scrollPane = new JScrollPane( panel );
setContentPane( scrollPane );
}
public static void main(String [] args){
ResizeImage frame = new ResizeImage();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
frame.setVisible(true);
}
}


---------------------------------


Read for more information.

http://www.roseindia.net/java/

Thanks.









Related Tutorials/Questions & Answers:
resize image with the change in size of jpanel.. - Java Beginners
resize image with the change in size of jpanel..  hi.. i am try to insert image in jpanel in jform to give attractive look to application,but the of image do not changes if the size of jframe or jpanel changes. if there is any
How to change image size before adding to mysql using jsp
How to change image size before adding to mysql using jsp  I want to upload an image to MySQL DB, before inserting the image I want to change the image size as per defined by me and then I want to store that image into my DB
Advertisements
Resize image stored in database
Resize image stored in database  hi, Can any one please send code for how to resize image stored in database in blob datatype in jsp, i want to resize it to 140(w)*160(h) please help me
Image Resize in Flex
Image Resize in Flex  Hi....... I am going to add images into a tag. How will it resize itself? Please tell me about that.... Thanks  Ans: The image resize is the part of laying out of your application. you
ModuleNotFoundError: No module named 'image_resize'
ModuleNotFoundError: No module named 'image_resize'  Hi, My Python... 'image_resize' How to remove the ModuleNotFoundError: No module named 'image_resize' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-resize-image'
ModuleNotFoundError: No module named 'python-resize-image'  Hi, My... named 'python-resize-image' How to remove the ModuleNotFoundError: No module named 'python-resize-image' error? Thanks   Hi
Validating image size
Validating image size  How to validate image size to 2MB in javascript which is updating to mysql database
dynamic image change javascript
dynamic image change javascript  How to display images in JavaScript dynamically
resize dynamic image in jsp - JSP-Servlet
resize dynamic image in jsp  Sir, I am saving the images in mysql...:- I am getting my image with this code but all I need that I want to resize that image automatically according to given dimension after retrieving on web page
Jmagick get image size
Jmagick get image size  Hi, How I can get the image size while using... to get the image size when using Jmagick ImageInfo ii = new ImageInfo(path...; hi, the code given below may help you to get the image size when using
Change JPanel background color from mouse entered/exit event
Change JPanel background color from mouse entered/exit event  I have a JPanel with a grid layout and I populated it with anonymous JPanels..."); and I got it to work that way but I couldn't get the tile JPanels to change color
PHP GD Image Resize
) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0...($tn, $save, 100); echo("Image created and saved successfully."
change the name of the image after uploading the image
change the name of the image after uploading the image   my form consists of a textbox and uploading the image.after uploading the image i want to change the name of the image with the content of the textbox before saving
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so when click the button then open the second panel same place of first panel
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so when click the button then open the second panel same place of first panel
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so when click the button then open the second panel same place of first panel
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so when click the button then open the second panel same place of first panel
Get Image Size Example
Get Image Size Example       This Example shows you get the image size... the default toolkit. Toolkit.getImage() : getImage method return a Image
Displaying the same image in a JPanel and using scroll - HELP - Java Beginners
Displaying the same image in a JPanel and using scroll - HELP  I hope someone can help me out here. I want to display an image in a JPanel which contain a Scroll, so using the scroll I want to see the first image displayed
How to decrease image thumbnail size in java?
How to decrease image thumbnail size in java?  Hi, I my web application I have to create the thumbnail size image from the image file uploaded by user. How to decrease image thumbnail size in java? Thanks
ModuleNotFoundError: No module named 'docker-image-size-limit'
ModuleNotFoundError: No module named 'docker-image-size-limit'  Hi...: No module named 'docker-image-size-limit' How to remove the ModuleNotFoundError: No module named 'docker-image-size-limit' error? Thanks   
ModuleNotFoundError: No module named 'docker-image-size-limit'
ModuleNotFoundError: No module named 'docker-image-size-limit'  Hi...: No module named 'docker-image-size-limit' How to remove the ModuleNotFoundError: No module named 'docker-image-size-limit' error? Thanks   
ModuleNotFoundError: No module named 'opsdroid-get-image-size'
ModuleNotFoundError: No module named 'opsdroid-get-image-size'  Hi...: No module named 'opsdroid-get-image-size' How to remove the ModuleNotFoundError: No module named 'opsdroid-get-image-size' error? Thanks   
Animate image in jQuery
;/head> <body> <div>Click Image to change the image Size.</br>... the JavaScript work. Here we takes a small example, that will resize the image... is the .animate() method is, in jQuery. It helps you to change the size of an images
Image Size
Image Size       This Java awt (Abstract Windowing Toolkit) tutorial describes about the image size... the size of its. For setting an image on the frame, you will need an image that have
How to Set Transperent Background Image to Jpanel - Java Beginners
How to Set Transperent Background Image to Jpanel  Sir ,How to set Background Image to Jpanel.  Hi Friend, Try the following code...); } } ); JTextArea area=new JTextArea(15,4){ ImageIcon image = new
Change Size of PowerPoint Slide Using Java
Change Size of PowerPoint Slide Using Java  ... then change the size of the slide. setPageSize(java.awt.Dimension pgsize): This method is used to change the size current page. The size of page is passed
UIButton Image Size
UIButton Image Size In this example we are going to discuss about how to set image size and setting image as a UIButton background. We are doing... frame for button //add image on button UIImage *buttonImage = [UIImage
uploading of image showing exception when size increases.
uploading of image showing exception when size increases.  Hi . I have a project in which the user can upload images. it works properly, but when the image size increases to arnd 1 MB or more it shows exception. I am using tomcat
Photoshop change a background image
Photoshop: change a background image   ... to change the background of an image. If you want to try this then this tutorial... in which you want to change the background image. I have selected an image
size of the image - Java Server Faces Questions
size of the image  Hello, how to set the size of the image while Inserting image in the pdf file using i text  Hi friend,import java.io....;)); doc.open(); Image image = Image.getInstance ("devi.jpg"); doc.add(new
How to change the color of a base64-encoded png image JQuery?
How to change the color of a base64-encoded png image JQuery?  I am going to change the colors of the pixels of a png image(which is in base64 format.... the original image is shown, but the color does not change. Do you know why
iPhone Font Size
iPhone Font Size In this example we are going to change the iphone font size and color. You can change the font size and font type using... types like Courier, Times New Roman etc... with different size.  You can
Objective C resize UIImage
Objective C resize UIImage  i just want to resize the image on the touch detection. That means if a user double clicks on the UIImage it must resize the image
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
What is the maximum size of a file that can be uploaded using PHP and how can we change this?  What is the maximum size of a file that can be uploaded using PHP and how can we change
How can we get the properties (size, type, width, height) of an image using php image functions?
How can we get the properties (size, type, width, height) of an image using php image functions?  How can we get the properties (size, type, width, height) of an image using php image functions
Jpanel allignment
Jpanel allignment  i have two panels added one below anotehr. and i have a one button. when i clicked button. the first panel ara should be overlapped with second panel. i mean second panel size should cover both paenls size
resize the tiff file - WebSevices
resize the tiff file  please guide me how i resize the tiff file and i want to upload it?   You can resize the tiff image as well as other type image. I am sending code, i hope it will help to you... Thanks
scrollbar in JPanel
the panel layout is null. If i change the panel layout to flow or grid its working. I... f = new Frame ("Demo");JPanel p = new JPanel();JButton b1 = new...) { Frame f = new Frame ("Demo"); JPanel p = new JPanel(); JButton b1 = new JButton
Mysql Alter Column Size
Mysql Alter Column Size       Mysql Alter Column Size is used to change the data size... 'employees' and change the size of column datatype.ADS_TO_REPLACE_6
Resize Header in CSS
Resize Header in CSS  Hi all, Please let me know if we can resize...;We can resize header tags in CSS .. and further call that class into you HTML file. h1{ font-size:60px;} h2{ font-size:48px;} h3{ font-size:36px
how to re size image proportionately using java for different images like jpeg, png, gif.
how to re size image proportionately using java for different images like jpeg, png, gif.  hi, i need sample code for re size image proportionately using java for different images like jpeg, png, gif, this code for my
SQL Alter Column Size
is used when you want to change the data type size. Understand... to change the size of data type of your field. In this case, we modify the size... SQL Alter Column Size      
Scroll in JPanel
static void main(String[] args) { Frame f = new Frame ("Demo"); JPanel p = new JPanel(); JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button 2
UIButton Image Change
UIButton Image Change In this series of iPhone UIButton examples, we are going... a button to changing images on button action. To change the image on button.... Code to change image on Button Action - (IBAction)buttonClicked:(id)sender
resize the tiff file in php - WebSevices
resize the tiff file in php  please guide me how i resize the tiff... if (($_FILES["file"]["type"] == "image/tiff") || ($_FILES["file"]["type"] == "image/tif")) { if ($_FILES["file"]["error"] > 0){ echo "Return Code
MX Resize Effect in Flex4
the size of component using Resize effect. The tag of Resize effect is <mx... for control the size of image." x="103" y="40...MX Resize Effect in Flex4: The Resize effect changes the height, width or both

Ads