Java Eclipse WindowBuilder - Как сохранить форму регистрации / регистрации в текстовом файле? - PullRequest
0 голосов
/ 03 марта 2020

Здравствуйте. Я делаю систему заказа еды с использованием Java Eclipse WindowBuilder, где вам нужно зарегистрироваться или зарегистрироваться, чтобы ваши данные были сохранены в текстовый файл, поэтому при входе с использованием предоставленных вами данных он будет сканировать TXT-файл и проверьте свою учетную запись

это мои коды для регистрации

package BearFoodExpress;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTable;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JPasswordField;
import javax.swing.JEditorPane;
import javax.swing.JList;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;

public class foodExpressSignUp {

    private JFrame frame;
    private JTextField txtFirstName;
    private JTable table;
    private JTextField txtLastname;
    private JComboBox<?> comboBox;
    private JTextField txtHouse;
    private JTextField txtStreet;
    private JTextField txtVillagebarangay;
    private JTextField txtLandmark;
    private JTextField txtMobileNo;
    private JTextField txtEmailAdd;
    private JPasswordField pwdReenterPassword;
    private JTextField txtPassword;

    /**
     * Launch the application.
     */
    public static void signUp() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    foodExpressSignUp window = new foodExpressSignUp();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public foodExpressSignUp() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 403, 541);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JLabel lblExpress = new JLabel("Express");
        lblExpress.setBounds(41, 26, 55, 20);
        frame.getContentPane().add(lblExpress);

        JLabel lblBearFood = new JLabel("Bear Food");
        lblBearFood.setBounds(41, 11, 62, 20);
        frame.getContentPane().add(lblBearFood);

        txtFirstName = new JTextField();
        txtFirstName.setText("First Name*");
        txtFirstName.setToolTipText("");
        txtFirstName.setBounds(41, 149, 151, 20);
        frame.getContentPane().add(txtFirstName);
        txtFirstName.setColumns(10);

        JButton btnSignUp = new JButton("Sign Up");
        btnSignUp.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {

                foodMenu sc2 = new foodMenu();
                sc2.mainMenu();

            }
        });
        btnSignUp.setBounds(70, 435, 89, 23);
        frame.getContentPane().add(btnSignUp);

        table = new JTable();
        table.setBackground(Color.PINK);
        table.setBounds(0, 0, 440, 46);
        frame.getContentPane().add(table);

        JLabel lblConfrimRegister = new JLabel("REGISTER");
        lblConfrimRegister.setFont(new Font("Tahoma", Font.BOLD, 16));
        lblConfrimRegister.setBounds(10, 57, 93, 20);
        frame.getContentPane().add(lblConfrimRegister);

        JLabel lblFillUpThe = new JLabel("Fill up the form below:");
        lblFillUpThe.setBounds(20, 82, 114, 20);
        frame.getContentPane().add(lblFillUpThe);

        JLabel lblfieldsWith = new JLabel("(Fields  with * are required)");
        lblfieldsWith.setBounds(20, 98, 139, 20);
        frame.getContentPane().add(lblfieldsWith);

        JLabel lblFirstName = new JLabel("FULL NAME");
        lblFirstName.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblFirstName.setBounds(41, 129, 67, 20);
        frame.getContentPane().add(lblFirstName);

        txtLastname = new JTextField();
        txtLastname.setToolTipText("");
        txtLastname.setText("Last Name*");
        txtLastname.setColumns(10);
        txtLastname.setBounds(209, 149, 151, 20);
        frame.getContentPane().add(txtLastname);

        JLabel lblLocation = new JLabel("LOCATION");
        lblLocation.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblLocation.setBounds(41, 180, 67, 20);
        frame.getContentPane().add(lblLocation);

        comboBox = new JComboBox();
        comboBox.setModel(new DefaultComboBoxModel(new String[] {"Select City or Municipality*", "Quezon CIty", "Pasay City", "Pasig CIty"}));
        comboBox.setBackground(Color.WHITE);
        comboBox.setEnabled(true);
        comboBox.setEditable(true);
        comboBox.setToolTipText("");
        comboBox.setBounds(70, 200, 197, 23);
        frame.getContentPane().add(comboBox);

        txtHouse = new JTextField();
        txtHouse.setToolTipText("");
        txtHouse.setText("House #");
        txtHouse.setColumns(10);
        txtHouse.setBounds(70, 225, 49, 20);
        frame.getContentPane().add(txtHouse);

        txtStreet = new JTextField();
        txtStreet.setToolTipText("");
        txtStreet.setText("Street*");
        txtStreet.setColumns(10);
        txtStreet.setBounds(124, 225, 95, 20);
        frame.getContentPane().add(txtStreet);

        txtVillagebarangay = new JTextField();
        txtVillagebarangay.setToolTipText("");
        txtVillagebarangay.setText("Village/Barangay");
        txtVillagebarangay.setColumns(10);
        txtVillagebarangay.setBounds(224, 225, 136, 20);
        frame.getContentPane().add(txtVillagebarangay);

        txtLandmark = new JTextField();
        txtLandmark.setToolTipText("");
        txtLandmark.setText("Landmark");
        txtLandmark.setColumns(10);
        txtLandmark.setBounds(70, 247, 120, 20);
        frame.getContentPane().add(txtLandmark);

        JLabel lblContactDetails = new JLabel("CONTACT DETAILS");
        lblContactDetails.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblContactDetails.setBounds(41, 278, 114, 20);
        frame.getContentPane().add(lblContactDetails);

        txtMobileNo = new JTextField();
        txtMobileNo.setToolTipText("");
        txtMobileNo.setText("Mobile No. *");
        txtMobileNo.setColumns(10);
        txtMobileNo.setBounds(72, 300, 147, 20);
        frame.getContentPane().add(txtMobileNo);

        JLabel lblEmailAddress = new JLabel("EMAIL ADDRESS");
        lblEmailAddress.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblEmailAddress.setBounds(41, 331, 114, 20);
        frame.getContentPane().add(lblEmailAddress);

        txtEmailAdd = new JTextField();
        txtEmailAdd.setToolTipText("");
        txtEmailAdd.setText("Email add. *");
        txtEmailAdd.setColumns(10);
        txtEmailAdd.setBounds(70, 353, 147, 20);
        frame.getContentPane().add(txtEmailAdd);

        JLabel lblPassword = new JLabel("PASSWORD");
        lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblPassword.setBounds(41, 384, 114, 20);
        frame.getContentPane().add(lblPassword);

        pwdReenterPassword = new JPasswordField();
        pwdReenterPassword.setBounds(211, 404, 149, 20);
        frame.getContentPane().add(pwdReenterPassword);

        txtPassword = new JTextField();
        txtPassword.setToolTipText("");
        txtPassword.setText("Password*");
        txtPassword.setColumns(10);
        txtPassword.setBounds(45, 404, 147, 20);
        frame.getContentPane().add(txtPassword);

        JLabel lblReenterPassword = new JLabel("Re-enter password*");
        lblReenterPassword.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblReenterPassword.setBounds(209, 384, 114, 20);
        frame.getContentPane().add(lblReenterPassword);

        JButton btnCancel = new JButton("Cancel");
        btnCancel.setBounds(70, 467, 89, 23);
        frame.getContentPane().add(btnCancel);
    }
}

, что делать или как я могу сделать, чтобы данные, которые они закодировали, были сохранены во внешний текстовый файл ? Спасибо

...