how to upload photo

Ads
 

how to upload photo

View Answers

March 13, 2009 at 5:32 AM

Hi Friend,

Please try the following code for solving problem.

// Code Starts

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

public class JLabelUploadImage{
public static void main(String[] args){
JFrame frame = new JFrame("Upload Image");
final JFileChooser fc = new JFileChooser();
JButton browse = new JButton("Browse File");
browse.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
int returnval = fc.showOpenDialog(null);
if (returnval == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
System.out.println(file.getName());
}
}
});
JButton button = new JButton("Upload Image");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
// Add functionality for inserting image into database
}
});
JPanel panel = new JPanel();
JLabel photo = new JLabel();
ImageIcon img = new ImageIcon("Sample.jpg");
photo.setIcon(img);
panel.add(photo);
panel.add(browse);
panel.add(button);
frame.add(panel);
frame.setSize(700, 700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}

// Code Ends

I hope that this will help you a lot.

Thanks and Regards
RoseIndia Team

Ads









Related Tutorials/Questions & Answers:
upload photo in xcode
upload photo in xcode  how can i upload a photo in a view in xcode? i am a beginner in xcode please help me
Photo upload, Download
Photo upload, Download  Hi I am using NetBeans IDE for developing... from server side. I want to save the photo with a given name. How can i do... am loading photo. BufferedImage image=null; JFileChooser chooser = new
Advertisements
Upload Photo to Server
Upload Photo to Server  Hi I am using NetBeans IDE for developing..." . My question is how can i load this to the server machine so that this photo... i am loading photo. BufferedImage image=null; JFileChooser chooser
How to create and use Facebook Shared Photo Albums?
Video Tutorial - How to create and use Facebook Shared Photo Albums? Facebook... explaining the process to learn how to create Facebook Shared Photo Albums. Have... to the photos they add. Here’s how to create and use Facebook Share Photo Album
How to Upload Site Online?
How to Upload Site Online?  After designing and developing your... program is free for uploading a website? How to Upload Site Online? Thanks  ... the tutorial How to Upload Site Online. Thanks
photo uploading
photo uploading  i want the code upload the image in oracle database
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database and the file in folder  how to upload multiple files in jsp and saving the path in database and the file in folder I have created a form for the upload of files
How to upload file using JSP?
How to upload file using JSP?   Hi all, I m the beginner in JSP, I want to upload file on server in specific folder.   1)page.jsp... file upload form to the user</TITLE></HEAD> <
How to upload file on FTP Server
How to upload file on FTP Server  In my application there is a requirement of uploading the file on FTP server. How to upload file on FTP Server... is good and can be used in Java applications. Read FTP File Upload in Java for more
how to upload and download images in java?
how to upload and download images in java?  what is the code for uploading and downloading images in java? how do I make a photo gallery through JSP? I want to create a photo gallery for each user which can be viewed by all users
How to upload and download file in hadoop?
How to upload and download file in hadoop?  Hi, I am trying to learn to upload the file on the Hadoop HDFS and then download the same file for learning the process. How to upload and download file in hadoop? What
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
How to upload files to server using JSP/Servlet?
How to upload files to server using JSP/Servlet?  How to upload files to server using JSP/Servlet
how to upload file using FTP in java
how to upload file using FTP in java  hai, i want to upload file using FTP in java Webservices.. Tel me some Articles Regards Asha
How to Increase Upload File Size Limit in php
How to Increase Upload File Size Limit in php  Increase Upload File Size Limit for php script   Sometimes you need to upload large files. But the default file upload size settings restrict you to upload large files. PHP
UPLOAD
UPLOAD  how to upload image using html
How to upload image to server in j2me by multipart/form-data?
How to upload image to server in j2me by multipart/form-data?  Hi, I need upload data to java server from j2me 1.Two text messages and 3 capture... in multi part form data. 3.As write code to upload text and image.As it is working
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to upload a student time table excelsheet
how to upload a student time table excelsheet   Hi good morning iam beginer iam doing project using struts frame work backend as 10g xe front end as java .in my student module i have time table so how to upload excelsheet
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp and servlet to upload images to the database. however i have difficulty in uploading...;tr> <center><td colspan="2"><B>UPLOAD THE FILE</B><
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp and servlet to upload images to the database. however i have difficulty in uploading...;tr> <center><td colspan="2"><B>UPLOAD THE FILE</B><
photo album
photo album  while syncing photos to my photo album in my iphone, the photo albumj ust got crashed i guess. Under photos option i just have the camera roll option now!! What should i do to get the photo album back
Adding photo to iPhone simulator
Adding photo to iPhone simulator  Hi, there is no photo in my iPhone simulator.. how can i add one? Please suggest. Thanks
how to upload a file of apk format in a folder from servlet
how to upload a file of apk format in a folder from servlet  How to upload a file of apk format to a folder from servlet, i am trying to do, its getting uploaded as .zip file and not apk file
photo viwer
photo viwer  i need coding for photo viewer using jsp mysql   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml
Gallery Photo
Gallery Photo  I need to display a photo gallery with the path stored in oracle with the possibility of their supprission (photo management) (with jsf or with jsp)   hi friend, Do not do such task using JSP, Better
How display a image on servlet from file upload - JSP-Servlet
How display a image on servlet from file upload  Dear Sir, My issue is: How display a image on servlet from file upload I receive your answer today... upload page Employee Image
How to upload zip file from android to server programmatically?????
How to upload zip file from android to server programmatically?????  hi , I want to upload zip file from android phone sdcard to server programmatically. So any one do this task in past so please share your experience with me

Ads