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



Home Answers Viewqa Java-Beginners how to upload photo
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


hendra
how to upload photo
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners



Advertisement
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... 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
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
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
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
photo uploading
photo uploading  i want the code upload the image in oracle database
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
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
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
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 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
UPLOAD
UPLOAD  how to upload image using html
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
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
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
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
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
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
iPhone Pick images from Photo Library
iPhone Pick images from Photo Library In this example application we are going to show you how to pick an image from photo library. To choose the photo from the photo library we required to call three different delegates
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
Advertisements
 

 

 

DMCA.com