Results 1 to 4 of 4
- 01-23-2009, 06:35 AM #1
BROWSING and ATTACHING MORE THAN ONE FILES IN JAVA
:)
KINDLY Help me with a code for browsing i.e.on clicking BROWSE button , window should appear from which any file on local system can be selected.
and attaching i.e. on clicking ATTACH button selected file should be attached in report so that user can see the attached file
eg As in yahoo or gmail we can browse and attach files which can be opened by user.
Thanks For Valuable Suggestions In Advance :)
- 01-23-2009, 08:49 AM #2
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
/*this is how you select a file assuming your requirement to be swing based gui application, attaching the file will depend upon the apis supported by the reporting tool you are using*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class FileSelectionDialog extends JFrame implements ActionListener{
private String _selectedFileName;
private JButton _btnSelectFile;
public FileSelectionDialog(){
_btnSelectFile=new JButton("Select File");
setLayout(null);
_btnSelectFile.setBounds(10,10,100,30);
add(_btnSelectFile);
setSize(200,200);
setVisible(true);
_btnSelectFile.addActionListener(this);
}
public static void main(String args[]){
new FileSelectionDialog();
}
public void actionPerformed(ActionEvent e){
JFileChooser jf=new JFileChooser();
jf.showOpenDialog(this);
File file=jf.getSelectedFile();
String fname=file.getName();
System.out.println("File selected::"+fname);
}
}Last edited by dswastik; 01-23-2009 at 08:53 AM.
- 01-23-2009, 12:00 PM #3
Thanks for your valuable suggestion.
I want to save the attached file like a document.
Thankyou
- 01-23-2009, 12:11 PM #4
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Similar Threads
-
Attaching the Java documentation
By Eranga in forum NetBeansReplies: 11Last Post: 08-09-2010, 04:17 AM -
[SOLVED] Attaching a mouseListener to a TreeViewer
By xcallmejudasx in forum New To JavaReplies: 1Last Post: 11-10-2008, 07:38 PM -
Attaching a drop-down box within a view(not toolbar)
By xcallmejudasx in forum EclipseReplies: 1Last Post: 10-28-2008, 06:59 PM -
[SOLVED] Attaching/Including extra package
By Eranga in forum NetBeansReplies: 16Last Post: 07-01-2008, 10:25 AM -
conversion of java .class files to .java files
By kotturupraveen in forum New To JavaReplies: 2Last Post: 06-09-2008, 12:58 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks