how to write function of copy from one to another location in this code
I need to write a code to copy a file from one location to another using browse button in it. i have written code for the browse button. please help me to add code for copy using swing!! thanks in advance.**
/*
For Browse button.
*/
package com.design;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Browse extends JFrame implements
ActionListener {
JButton button1, button2 ;
JTextField field1, field2;
public Browse () {
this.setLayout(null);
button1 = new JButton("Browse");
field1 = new JTextField();
field1.setBounds(30, 50, 200, 25);
button1.setBounds(240, 50, 100, 25);
this.add(field1);
this.add(button1);
button2 = new JButton("Copy");
button2.setBounds(150, 150, 100, 25);
this.add(button2);
button1.addActionListener(this);
setDefaultCloseOperation
(javax.swing.WindowConstants.EXIT_ON_CLOSE
);
}
public void actionPerformed(ActionEvent e) {
Chooser frame = new Chooser();
field1.setText(frame.fileName);
}
public static void main(String args[]) {
Browse frame = new Browse ();
frame.setSize(400, 300);
frame.setLocation(200, 100);
frame.setVisible(true);
}
}
class Chooser extends JFrame {
JFileChooser chooser;
String fileName;
public Chooser() {
chooser = new JFileChooser();
int r = chooser.showOpenDialog(new JFrame());
if (r == JFileChooser.APPROVE_OPTION) {
fileName = chooser.getSelectedFile().getPath();
System.out.println(fileName);
}
}
}
View Answers
Ads
Related Tutorials/Questions & Answers:
Advertisements
File copy from one directory to another in java
File
copy from one directory to
another in java I am trying to find very good
code example for copying a file
from one directory to
another...
from a directory to
another directory.
How to achieve this? Is there any API
Copy one file into another
Copy one file into
another
In this section, you will learn
how to
copy content of
one file into
another
file. We will perform this operation by using...;This string is copied
from one file to
another\n");
bf.close();
InputStream
how to pass a string from one class to another
how to pass a string
from one class to another hi all, Good morning... string
from one class to
another.
import java.util.*;
class A{
static String... string
from one class to
another.
import java.io.*;
class Class1 {
public
How to forward the control from one jsp to another?
How to forward the control
from one jsp to
another? Hi!
This is Prasad Jandrajupalli.
I have the 3 JSP's, but I want communicate with each... is not communicate with the Third JSP.
I want forward the control
from first jsp to second
How to navigate from one jsf to another in eclipse
How to navigate
from one jsf to
another in eclipse Hi there is my jsf
code...
<%@ page language="java" contentType="text/html; charset... using the above
code for my welcome page which ask for user name and after
Java - Copying one file to another
;
This example illustrates
how to
copy contents
from one... the contents
from one specified file to
another specified file.
copyfile(String... to
another specified file
from the first
one specified file.
// For creating a byte
How to pass variable from one class to another in java
How to pass variable
from one class to
another in java
How to pass variable
from one class to
another in java?
Example:
public class...;
}
}
//
Another class Class2.
public class Class2 {
public static void main(String
How To Pass data from one GUI to another in java swing
How To Pass data
from one GUI to
another in java swing I'm new to java and part of our assignment is to build a GUI and display a result set
from data input. I'm stuck at
how to get the user's input
from JTextFields and combobox
Copy One Database Table to Another
Copy One Database Table to
Another
 ... to
another database table. That means we
copy one table to a different table...;java CopyOneDatabaseTableToAnother
Copy data
from one database table
Copying an array to another
Copying an array to
another
Java
Copy Array Example:In this tutorial, you will learn
how to
copy data
from one array to
another.
Here, providing you an example with
code
update one table from another table
update
one table
from another table hello, i need to update
one table fields by using
another table fields. I have to tables Products.... for example TotalQuantity field
from Products table should be updated if i
copying data from one table to another
copying data
from one table to another i need to
copy data
from one table to
another table..
i.e the 1st eid of employee table must be copied... and so on...
i need these querys to use in my JSP
code
How to copy a file in java
. In
another way we can
copy using File I/o
Stream.
Example: Java
Code to
copy...
How to
copy a file in java
In this section you will learn about
how to
copy a content of
one file to
another file. In java, File API will not provide any
passing data from one jframe to another
passing data
from one jframe to another I have two JFrame,built by using the GUI Editor netbeans 6.9.i have to pass a data
from a Jtextfield in the first Jframe to
another JLabel in the other JFrame.Can you please help me,
how
to bring checked data from one page to another
to bring checked data
from one page to another thanks for your help... there is
one jsp page , on it there is a link, on click of which it is opening second... fetching data
from the database on second jsp page with checkbox corresponding each
how to change password into one jsp to another jsp
how to change password into
one jsp to
another jsp i have two jsps in
one jsp i give
one password and confirm password, in
another jsp i want change my password compare with 1st jsp
how to
write code please give me answer?