Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners resize image with the change in size of jpanel..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


pankaj
resize image with the change in size of jpanel..
1 Answer(s)      6 years and 4 months ago
Posted in : Java Beginners



Advertisement
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
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
Advertisements
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
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
PHP GD Image Resize
= imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100); echo("Image created
Validating image size
Validating image size  How to validate image size to 2MB in javascript which is updating to mysql database
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
dynamic image change javascript
dynamic image change javascript  How to display images in JavaScript dynamically
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 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
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
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
Image Size
Image Size       This Java awt (Abstract Windowing Toolkit) tutorial describes about the image size...; This program helps you in setting an image and getting the size of its
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
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
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... for button //add image on button UIImage *buttonImage = [UIImage imageNamed:@"
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... want to change the background image. I have selected an image of two person
Animate image in jQuery
; <div>Click Image to change the image Size.</br> <img src="... 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
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
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
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
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
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
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
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
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 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
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. mysql> alter
Advertisements
 

 

 

DMCA.com