how to upload photo

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









Related Tutorials/Questions & Answers:
how to upload photo - Java Beginners
how to upload photo  dear sir, I has a case like that, first i have jlabel. i want to view data like photo/picture to jlabel. then i have a button...{ public static void main(String[] args){ JFrame frame = new JFrame("Upload Image
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
Advertisements
Photo upload, Download
Photo upload, Download  Hi I am using NetBeans IDE for developing.... I want to save the photo with a given name. How can i do it. Should i have... am loading photo. (adsbygoogle = window.adsbygoogle || []).push
Upload Photo to Server
Upload Photo to Server  Hi I am using NetBeans IDE for developing... is how can i load this to the server machine so that this photo photo can... i am loading photo. (adsbygoogle = window.adsbygoogle || []).push
PHOTO UPLOAD AND DISPLAY - Struts
PHOTO UPLOAD AND DISPLAY  Hi, This is chandra Mohan. I want some help urgently from your side. My problem is I want to upload the photos and display photos usin Struts technology. Please give me some suggestion to me
Upload photo - Java Beginners
Upload photo  Morning, Can you tell me coding how to upload photo. First, i want to browse the photo from my direktory(*.jpg, *.bmp *.gif), then i click this photo and view in my JFrameForm then i have a button to save
Photo Upload - JSP-Servlet
Photo Upload  Dear Sir, I want some help you i.e code for image upload and download using Servle/jsp. Thanks&Regards, VijayaBabu.M ...(); %> You have successfully upload the file by the name
photo uploading
photo uploading  i want the code upload the image in oracle database
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... description of how you can create and use Facebook Shared Photo Albums
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
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
UPLOAD
UPLOAD  how to upload image using html
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
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
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> <
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 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
photo gallery - Java Beginners
photo gallery  Iam uploading images in the serverusing uploading... it dynamically with out giving the path. please help  Hi friend, For upload image visit to : http://www.roseindia.net/jsp/file_upload/employee_upload
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 a file - JSP-Servlet
how to upload a file  Dear sir, Give me some code...: Display file upload form to the user UPLOAD THE FILE   Choose the file To Upload:   2
save uiimage to photo library
save uiimage to photo library  How to saved the clicked picture on camera roll in iPhone. I always want to write the file into photo library.   Save UIImage to photo library Creating a camera application in iPhone need
ModuleNotFoundError: No module named 'mera_photo'
'mera_photo' How to remove the ModuleNotFoundError: No module named 'mera_photo' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'mera_photo'  Hi, My Python
ModuleNotFoundError: No module named 'natgeo_photo'
'natgeo_photo' How to remove the ModuleNotFoundError: No module named 'natgeo_photo' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'natgeo_photo'  Hi, My Python
ModuleNotFoundError: No module named 'natgeo_photo'
'natgeo_photo' How to remove the ModuleNotFoundError: No module named 'natgeo_photo' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'natgeo_photo'  Hi, My Python
ModuleNotFoundError: No module named 'photo-org'
'photo-org' How to remove the ModuleNotFoundError: No module named 'photo...ModuleNotFoundError: No module named 'photo-org'  Hi, My Python... have to install padas library. You can install photo-org python with following
ModuleNotFoundError: No module named 'photo-calendar'
named 'photo-calendar' How to remove the ModuleNotFoundError: No module named 'photo-calendar' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'photo-calendar'  Hi, My
ModuleNotFoundError: No module named 'photo-dl'
'photo-dl' How to remove the ModuleNotFoundError: No module named 'photo-dl...ModuleNotFoundError: No module named 'photo-dl'  Hi, My Python... to install padas library. You can install photo-dl python with following
ModuleNotFoundError: No module named 'photo-gen'
'photo-gen' How to remove the ModuleNotFoundError: No module named 'photo...ModuleNotFoundError: No module named 'photo-gen'  Hi, My Python... have to install padas library. You can install photo-gen python with following
ModuleNotFoundError: No module named 'photo-grid'
'photo-grid' How to remove the ModuleNotFoundError: No module named 'photo-grid' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'photo-grid'  Hi, My Python
ModuleNotFoundError: No module named 'photo-import'
'photo-import' How to remove the ModuleNotFoundError: No module named 'photo-import' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'photo-import'  Hi, My Python
ModuleNotFoundError: No module named 'photo-org'
'photo-org' How to remove the ModuleNotFoundError: No module named 'photo...ModuleNotFoundError: No module named 'photo-org'  Hi, My Python... have to install padas library. You can install photo-org python with following
ModuleNotFoundError: No module named 'photo-sorter'
'photo-sorter' How to remove the ModuleNotFoundError: No module named 'photo-sorter' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'photo-sorter'  Hi, My Python
ModuleNotFoundError: No module named 'photo-uploader'
named 'photo-uploader' How to remove the ModuleNotFoundError: No module named 'photo-uploader' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'photo-uploader'  Hi, My
ModuleNotFoundError: No module named 'unach-photo'
'unach-photo' How to remove the ModuleNotFoundError: No module named 'unach-photo' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'unach-photo'  Hi, My Python
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 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 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
how to upload resume coding - Java Beginners
how to upload resume coding  am doing a project for human resource management. where i 've to upload the resume (.doc file) for the user and store it in the mysql backend using jsp and javabeans... can anyone help me
ModuleNotFoundError: No module named 'photo-namer-nautilus'
: No module named 'photo-namer-nautilus' How to remove the ModuleNotFoundError: No module named 'photo-namer-nautilus' error? Thanks   Hi...ModuleNotFoundError: No module named 'photo-namer-nautilus'  Hi
ModuleNotFoundError: No module named 'phyto-photo-utils'
named 'phyto-photo-utils' How to remove the ModuleNotFoundError: No module named 'phyto-photo-utils' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'phyto-photo-utils'  Hi, My
ModuleNotFoundError: No module named 'phyto-photo-utils'
named 'phyto-photo-utils' How to remove the ModuleNotFoundError: No module named 'phyto-photo-utils' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'phyto-photo-utils'  Hi, My
ModuleNotFoundError: No module named 'simple-photo-gallery'
: No module named 'simple-photo-gallery' How to remove the ModuleNotFoundError: No module named 'simple-photo-gallery' error? Thanks   Hi...ModuleNotFoundError: No module named 'simple-photo-gallery'  Hi
ModuleNotFoundError: No module named 'unach-photo-server'
named 'unach-photo-server' How to remove the ModuleNotFoundError: No module named 'unach-photo-server' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'unach-photo-server'  Hi, My
ModuleNotFoundError: No module named 'wagtail-photo-voter'
named 'wagtail-photo-voter' How to remove the ModuleNotFoundError: No module named 'wagtail-photo-voter' error? Thanks   Hi...ModuleNotFoundError: No module named 'wagtail-photo-voter'  Hi, My
ModuleNotFoundError: No module named 'django-photo-albums'
named 'django-photo-albums' How to remove the ModuleNotFoundError: No module named 'django-photo-albums' error? Thanks   Hi...ModuleNotFoundError: No module named 'django-photo-albums'  Hi, My
How display a Image on Servlet from file upload - JSP-Servlet
How display a Image on Servlet from file upload  Dear Sir, My requirement is I want to display a Image on Servlet from File Upload... by photo gallery.that message show file format not supported by Photo Gallary. I

Ads