insert image in JFrame

insert image in JFrame

View Answers

December 10, 2009 at 10:28 AM

Hi Friend,

Try the following code:

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class ShowImage extends Panel {
BufferedImage image;
public ShowImage() {
try {
System.out.println("Enter image name\n");
BufferedReader bf=new BufferedReader(new
InputStreamReader(System.in));
String imageName=bf.readLine();
File input = new File(imageName);
image = ImageIO.read(input);
} catch (IOException ie) {
System.out.println("Error:"+ie.getMessage());
}
}

public void paint(Graphics g) {
g.drawImage( image, 0, 0, null);
}

static public void main(String args[]) throws
Exception {
JFrame frame = new JFrame("Display image");
Panel panel = new ShowImage();
frame.getContentPane().add(panel);
frame.setSize(500, 500);
frame.setVisible(true);
}
}

For more information, visit the following link:

http://www.roseindia.net/tutorial/java/swing/retrieveImage.html

Thanks









Related Tutorials/Questions & Answers:
insert image in JFrame - Development process
insert image in JFrame  how to insert a image in JFrame.please... = new JFrame("Display image"); Panel panel = new ShowImage... Panel { BufferedImage image; public ShowImage() { try
how to insert image into server
how to insert image into server  how to insert an image into sql server and retrieve it using jSP
Advertisements
setbackground image to JFrame - Java Beginners
setbackground image to JFrame   how to setbackground image to JFrame... TransparentBackgroundImage { public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener( new WindowAdapter() { public
insert image using hibernate
insert image using hibernate  Sir, Today I hadposted question regarding upload image, th answer you had given is using SQL, but I am using Hibernate to insert data in the same table where I want to insert image. Plz hlp me
hibernate insert image
hibernate insert image  Sir, Today I hadposted question regarding upload image, th answer you had given is using SQL, but I am using Hibernate to insert data in the same table where I want to insert image. Plz hlp me. Thanks
insert image - JSP-Servlet
insert image  hi friends i am mahesh i am trying to insert image... = connection.prepareStatement("insert into save_image(name, image) values...("unsucessfull to insert image."); } psmnt.close(); connection.close
Insert image in database
Insert image in database  Want a jsp-struts program in which the imageFile is in the form of getter and setter and inserted in the database as a Blob using . and then download the image and show on next jsp pg. No use
Java Image On JFrame Title
How to set Image On JFrame In this section, you will learn how to set an image on JFrame title using Java program. For this, we have created an object...() that will load the specified image and the method setIconImage() of JFrame class
image insert - Java Beginners
image insert  i browsed the image by clicking d browse button.if i press submit button means d image automatically stored in db.then i have 2 retrieve d image separately...................... Untitled Document
Insert and Retrieve Image - JSP-Servlet
, This is insert image code...Insert and Retrieve Image  Hello, I need source code using java servlet or jsp and html form and brief explanations on how to insert and retrieve
Can i insert image into struts text field
Can i insert image into struts text field  please tell me can i insert image into text field
Insert or retrieve image into oracle 10g by using java
Insert or retrieve image into oracle 10g by using java   How can i insert or retrieve image into oracle10g using java plz i need it urgently,need guidance to do this plz
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m working in a project where we have to capture an image using web cam. when... , the image column is of varchar datatype.. plz can you tell me how to insert image's
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframe
jframe  Create a JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
Insert Image In DB through Servlet - JSP-Servlet
Insert Image In DB through Servlet  Dear Sir, I want to add the Image In databse using servlet. I have a program Its fine run on command prompt...()); } } } Whether Any entry will be made in web.xml when Insert Image in Databse using servlet
Insert Image In DB through Servlet - JSP-Servlet
Insert Image In DB through Servlet  Dear Sir, My previous Query...(e.getMessage()); } } } Whether Any entry will be made in web.xml when Insert Image..., To insert image in Database using servlet to visit.... http://www.roseindia.net
Insert Image into Excel Sheet
Insert Image into Excel Sheet In this section, you will learn how to insert image into excel sheet using Apache POI. In the given below example, am image is insert into excel sheet at row 1 and at column 1. you can specify the top
Insert Image in DB through Servlet - JSP-Servlet
Insert Image in DB through Servlet  Dear Sir, My previous Query...(e.getMessage()); } } } Whether Any entry will be made in web.xml when Insert Image... Dear Sir, I already see this reference link which you give to insert the image
Insert Image In DB through Servlet - JSP-Servlet
Insert Image In DB through Servlet  Dear Sir, My previous Query...(e.getMessage()); } } } Whether Any entry will be made in web.xml when Insert Image...("insert into Image(id,imgName,image) values (?,?,?)"); File file= new File
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
Insert Image in DB through Servlet - JSP-Servlet
Insert Image in DB through Servlet  Dear Sir, You write me: copy this link and paste in your Url http://rs236.rapidshare.com/files/144453519/New... A new Page displayed, check there a Round Shaped Image Called "download" click
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
Insert Image in DB through Servlet - JSP-Servlet
Insert Image in DB through Servlet  Dear Sir, I am not able to solve my problem cocerning Inserting the image in Database through Servlet. I am usng... = conn.prepareStatement("insert into MyPictures values(?,?,?)"); pre.setInt(1,5
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database... = connection.prepareStatement("insert into file(file_data) values(?)"); fis = new
How to insert image in PDF file in struts2
How to insert image in PDF file in struts2 In this example, we will see how to insert image in PDF file using struts2.2.1 framework.. index.jsp <html>ADS_TO_REPLACE_1 <head><title>Insert title here<
how to insert and retrieve an image from mysql using java - Java Beginners
how to insert and retrieve an image from mysql using java  how to insert and retrieve an image from mysql using java?  Hi friend, Code to insert image using java : import java.sql.*; import java.io.*; class
insert name city image in database using mysql and jsp
insert name city image in database using mysql and jsp  how to insert... is an example in jsp that insert name, city and image to database. <%@ page import..."); PreparedStatement psmt=con.prepareStatement("insert into data(name,city,image)"+"values
How to insert and retreive an image in mysql database using spring mvc framework???
How to insert and retreive an image in mysql database using spring mvc framework???  I ve solved this problem based on the Product Search Application. Those who need this concept and code segment kindly copy it. Thanks and All
How to Insert image and data both together in database in JSP/Servlet ?
How to Insert image and data both together in database in JSP/Servlet ? ... = connection.prepareStatement("insert into data(Name,City,Img) values('"+nn+"','"+cc...(e.getMessage()); } } %> //if i remove below lines then it insert
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary...=con.prepareStatement("insert into inimage(name,city,image)"+"
insert
insert  insert data in database from servlet through JDBC   Ho Friend, Please visit the following:ADS_TO_REPLACE_1 Insert data into database Thanks
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
jframe
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Insert Image into Database Using Servlet
Insert  Image into Database Using Servlet   ... image into database table using Servlet. This type of program is useful in social... photograph of the user. If the image is stored in the database you can easily
Insert  Image into Database Using Servlet
Insert  Image into Database Using Servlet   ... of inserting image into database table using Servlet. This type of program is useful... photograph of the user. If the image is stored in the database you can easily
How to insert image in MySQL database using sql query?
Insert image in MySQL database using sql query  .... The video of this tutorial show you how you can insert the image into database... tutorial of "How to insert image in MySQL database using sql query?": So
Inserting Image in Database Table
;    In this section, you will learn to insert an image... This program helps the user to insert an image in the MySQL database table. To insert an image, you need to establish a connection with MySQL database
Difference between Normal Insert and BLOB insert
), DisplayImage (image). Table has 2 rows for first row i have written insert into Image... normal insert image.. I dont want to use AS BLOB in insert statement   ... parameter error. Here is a code that insert image into database: import java.sql.
how to reset JFrame
how to reset JFrame  how to reset JFrame
image
image  how to add the image in servlet code
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp

Ads