Fairly new to Java: JTextFields help!!!
From: DJM (DJM_666_at_msn.com)
Date: 03/28/04
- Next message: DJM: "Input Validation???"
- Previous message: may: "Running the Web Client in J2EE tutorial - no java compiler was found."
- Next in thread: Christophe Vanfleteren: "Re: Fairly new to Java: JTextFields help!!!"
- Reply: Christophe Vanfleteren: "Re: Fairly new to Java: JTextFields help!!!"
- Reply: Fahd Shariff: "Re: Fairly new to Java: JTextFields help!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Mar 2004 03:27:19 -0800
I have a program with a few JTextFields. How do I store what is input
into these fields in a text file?
Below is some sample code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GUI extends JFrame implements ActionListener
{
private JTextField jtfCustID, jtfTransType, jtfDiff, jtfOpeningBal,
jtfClosingBal, jtfTransDate;
private JButton jbConfirm;
public GUI()
{
this.setTitle("GUI");
this.setSize(400,300);
jtfCustID = new JTextField();
jtfTransType = new JTextField();
jtfDiff = new JTextField();
jtfOpeningBal = new JTextField();
jtfClosingBal = new JTextField();
jtfTransDate = new JTextField();
jbConfirm = new JButton("Confirmation");
Container cp = this.getContentPane();
cp.setLayout(new GridLayout(8,2));
cp.add(new JLabel("Customer ID"));
cp.add(jtfCustID);
cp.add(new JLabel("Transaction Type"));
cp.add(jtfTransType);
cp.add(new JLabel("Opening/Closing Difference"));
cp.add(jtfDiff);
cp.add(new JLabel("Opening Balance"));
cp.add(jtfOpeningBal);
cp.add(new JLabel("Closing Balance"));
cp.add(jtfClosingBal);
cp.add(new JLabel("Date of Transaction"));
cp.add(jtfTransDate);
cp.add(jbConfirm);
jtfCustID.addActionListener(this);
jtfTransType.addActionListener(this);
jtfDiff.addActionListener(this);
jtfOpeningBal.addActionListener(this);
jtfClosingBal.addActionListener(this);
jtfTransDate.addActionListener(this);
jbConfirm.addActionListener(this);
}// end constructor GUI()
public void actionPerformed(ActionEvent event){
if (event.getSource() == jbConfirm) ;
}// end method actionPerformed()
public static void main(String [] arg){
GUI frame = new GUI();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}//end method main()
}// end class GUI
What code would I have to use, to save (into a text file) what is
input into the: jtfCustID, jtfTransType, jtfDiff, jtfOpeningBal,
jtfClosingBal, and jtfTransDate fields?????
- Next message: DJM: "Input Validation???"
- Previous message: may: "Running the Web Client in J2EE tutorial - no java compiler was found."
- Next in thread: Christophe Vanfleteren: "Re: Fairly new to Java: JTextFields help!!!"
- Reply: Christophe Vanfleteren: "Re: Fairly new to Java: JTextFields help!!!"
- Reply: Fahd Shariff: "Re: Fairly new to Java: JTextFields help!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|