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

 
 


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

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 Pages:
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
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 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...;Use the button for control the size of image." x="103"...MX Resize Effect in Flex4: The Resize effect changes the height, width or both
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
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
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
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
How to save JPanel as gif or jpeg file
JButton("Make Image"); add(button); setPreferredSize(MAIN_SIZE...); Dimension size = win.getSize(); BufferedImage image = (BufferedImage...How to save JPanel as gif or jpeg file  i draw polygons , rectangles
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
JPanel - Container
() to change the layout. JPanel p = new JPanel(); p.setLayout(new FlowLayout... Java: JPanel - Container   Learn how to use the JPanel Container in a Swing application.   Swing comes with many components. The JPanel is one
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
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
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
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
Spark Resize effect in Flex4
and shrink the size of component using Resize effect.  The tag of Resize effect is <s:Resize>. In this example you can see how we can use a Resize...Spark Resize effect in Flex4: The Resize effect changes the height, width
Java: JPanel - Example
Java: JPanel - Example // Demo Application of use of JPanel for drawing...) { // When button is pressed, change colors if (flip == 1... ///////////////////////////////////////////////////////// DrawingArea class DrawingArea extends JPanel
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
i want to resize the tiff file also - WebSevices
']); $FileName= time().$objFiles['photo']['name']; $this->resize_image...'],180,135); } function resize_image($src,$dest,$type,$new_width,$new...i want to resize the tiff file also  if($objFiles['photo']['name
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
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
Mysql Alter Column Size
Mysql Alter Column Size       Mysql Alter Column Size is used to change the data size of a column...' and change the size of column datatype. mysql> alter table employees
Button Size HTML
HTML Button Size can be changed according to programmer use. HTML button submits HTML page. In the following example we will learn how to change the size... can add an image in the background, change the font of the text, color
inserting an path of an image in database - JDBC
inserting an path of an image in database  hello kindly help related... an image using web cam.... and when the image is saved in a project at the same... to save it in folder..but can you plz tell me how an the full path of image can
track file size changes
track file size changes  How to track a change in file size
convert tiff image to gif image - WebSevices
convert tiff image to gif image  please tell me "how to convert tiff image to gif image?" using php code for the purpose of "i want to upload and resize the tiff image?" plz inform if there any idea?   Hi I am
PHP GD image to text
); } $image = imagecreatetruecolor($full_x, $full_y); imagecopyresized($image, $file, 0, 0, 0, 0, imagesx($image), imagesy($image), imagesx($file), imagesy($file)); for ($y=0;$y<imagesy($image);$y++) { for ($x=0;$x<imagesx
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
SQL Alter Column Size
is used when you want to change the data type size. Understand...; modify and change the Table 'Stu_Table'. Now you want to change the size... SQL Alter Column Size      
iphone artwork size
iphone artwork size  Hi, What is the size of iphone artwork image? Thanks   Hi, It's 512x512 pixels. Thanks
How to change the face, change the face
How to change the face       You have a chance to learn how to change the face... that is given in this tutorial so let's try. Open an Image: First you have to open
How to change background, change background
How to change background       This example will teach you to change background of any object... a picture to change background. Selection: Make selection by the Magic wand tool
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
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... declared into the interface (ViewController.h) file. Code to change image
J2ME Display Size Example
the size of the screen. Like a below given image 1, the midlet will print few items on the screen and the screen size will be displayed at the command prompt (image 2).           Image 1 Image 2 To get the size
resize a panel slowly - IDE Questions
resize a panel slowly  How to code to resize a panel slowly with netbeans