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

Home Answers Viewqa Swing-AWT Java/PHP Developer

View Questions and Answers by Category


Have Programming Question? Ask it here!

Java/PHP Developer
1 Answer(s)      3 years and a month ago
Posted in : Swing AWT

help me with passing data from jframe to text file please.

View Answers

November 16, 2011 at 1:40 PM

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame
JButton ADD;
JPanel panel;
JLabel label1,label2,label3,label4,label5;
final JTextField text1,text2,text3,text4,text5;
label1 = new JLabel();
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("First Name:");
text2 = new JTextField(20);

label3 = new JLabel();
label3.setText("Last Name:");
text3 = new JTextField(20);

label4 = new JLabel();
text4 = new JTextField(20);

label5 = new JLabel();
text5 = new JTextField(20);

ADD=new JButton("ADD");

panel=new JPanel(new GridLayout(6,2));
ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
String value3=text3.getText();
String value4=text4.getText();
String value5=text5.getText();
BufferedWriter bw=new BufferedWriter(new FileWriter("data.txt",true));
bw.write(value1+" "+value2+" "+value3+" "+value4+" "+value5);
JOptionPane.showMessageDialog(null,"Data is inserted into file.");
catch(Exception e){

class FormDemo
public static void main(String arg[])
Form frame=new Form();
catch(Exception e)

Related Tutorials/Questions & Answers:
Java/PHP Developer
Java/PHP Developer  how to remove and add a new contentpane on same frame do we have any methods
Java/PHP Developer
Java/PHP Developer  please help me to bring cell values of jtable to a text file
Java/PHP Developer
Java/PHP Developer  help me with passing data from jframe to text file please
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box
Java/PHP Developer
Java/PHP Developer  Hi, I need a cloak embedded in java swing frame or panel..And it should not change when system time is changed ..please
Java/PHP Developer
Java/PHP Developer  Hi, can u help me to embedd time on java frame and it should be independent of operating system time..if we change system time it should'nt be changed.. Thank you sir
Java/PHP Developer
Java/PHP Developer  how can we get words seperated by delimeters in text file can be imported in jframe like one word for one line
Java/PHP Developer
Java/PHP Developer  Hi, how to create radio buttons on one pannel and should change when pressed ok... can u help me htrough this sooner... THANK U
Java/PHP Developer
Java/PHP Developer  Hi, can u please help me with this, I have a text file with 3 sentences separated by delimiters and i want to get each sentence in different JFrames when press ok button on first frame it should close
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box..... like a text file containing questions and another text file containing answer of 3 r 4 options,each one
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box..... like a text file containing questions and another text file containing answer of 3 r 4 options,each one
Java/PHP Developer
Java/PHP Developer  Hi, I have a textfile(notepad1.txt) with 1 question and another textfile(notepad2.txt) with answers(4 options like multiple choice),question is imported from first text file to jframe and 4 options with check
Java/PHP Developer
Java/PHP Developer  HI, I want to know how can we place a link in one jframe to open a videopanel. import; import... } // end MediaPanel constructor } // end class MediaPanel   Java create
Java/PHP Developer
Java/PHP Developer  Hello sir, Am working on playing audio file in jframe and im not able to import into the code.. the code.../java/javase/download-142937.html After downloading, put the jar file under the lib
plsql developer
plsql developer  how did plsql developer provided the information to the frent end people when ever they contact plsql developer and how plsql developer tck the data from the database
Java Developer
Java Developer  Hi, I am engineering student. I want to make career in as Java Developer. How to become a Java Developer? What programming languages... an expert Java Developer? Thanks
Developer Files - Development process
Developer Files  Hi, I dont have real time experience. can u tell as a j2ee developer should i edit struts properties files or not . like wise changes in any other properties file. Thanks Prakash
Developer discussion forums
Developer discussion forums  Hi, What is discussion forums? Is there any good forum for discussion programming technologies? Thanks   Hi... - Developer discussion forums Thanks
Hire iPhone developer
Hire iPhone developer - Hire iPhone developers in India Apple?s iPhone... few efficient developer in this field. If you want to develop any outstanding... iPhone app developer who can develop an iPhone application that can run
Mozilla Developer Center
Mozilla Developer Center       Great site to get a first look at AJAX. Read full Description
iPhone apps developer
iPhone apps developer With the launch of Apple's innovative product iPhone that comprises three advanced products in it-a smart mobile, a faster internet connection and advanced multimedia devices with touch screen and virtual
Looking to Hire Magento Website Developer?
Looking to Hire Magento Website Developer?  Are you searching for Magento ecommerce development solution? Then you have arrived on the right place... at reasonable prices. You can hire Magento ecommerce developer from us
Perl Developer
Perl Developer       Position Vacant: Perl Developer Job Description  We... Years  Keywords: Perl, Developer, Unix Scripting, Linux Scripting, Shell
How to become a PHP Developer?
PHP developer. This explains you all the technologies you have to learn to become a PHP Developer. You will definitely find this step-by-step tutorial very.... To become a PHP developer following the following steps: How to become PHP
Java Developer
Java Developer  What is scenario where i use interface and where use interface
Java Developer
Java Developer  where we should use interface and where we should use abstract class
java developer
java developer  i didnt get the correct ANSWER PLZ EXECUTE THE FOOLWING SERVLET BY USING DATABASE USERLOGIN TABLE VALUES. //validate login.html <html> <body> <body bgcolor="wheat"> <center>
Software Developer
Software Developer  what is the java code to turn off my pc
JDK 8 - Developer Preview Released
JDK 8 - Developer Preview Released, Check the features of JDK , Download JDK 8 Developer preview release and share you comments with community Java... of the JDK 8 is to provide an open source context for the utilization of the Java SE