How to display jtextfield content on jtextarea

49 views Asked by At

this the GUI I am trying to display the the inputs of my Jtextfield onto the text area but the contents are not displaying this is my code

import javax.swing.*;
import java.awt.*; 
import java.awt.event.ActionEvent; 
import java.awt.event.ActionListener;
 
public class FUEL1 extends JDialog {
    private JPanel panel1;
    private JTextArea tADIS;
    private JTextField TFcom;
    private JTextField TFid;
    private JTextField TFfuel;
    private JButton btnAPP;
    private JButton bTNPRINT;
    private JPanel panel2;

    String cid;
    int amount;
    int tax;

    public void print() {
        String name = TFcom.getText();
        String cid = TFid.getText();
        String amount = TFfuel.getText();

        tADIS.setText(tADIS.getText() + "\n");
        tADIS.setText(tADIS.getText() + "TAX EXEMPTION REPORT" + "\n");
        tADIS.setText(tADIS.getText() + "Customer id:" + cid + "\n");
        tADIS.setText(tADIS.getText() + "Company name:" + name + "\n");
        tADIS.setText(tADIS.getText() + "AMount in liters:" + amount + "\n");
        tADIS.setText(tADIS.getText() + "tax exempted:" + tax + "\n");
    }

    public FUEL1(JFrame parent) {
        super(parent);
        setTitle("home page");
        setContentPane(panel1);
        setMinimumSize(new Dimension(450, 450));
        setModal(true);
        setLocationRelativeTo(parent);
        setVisible(true);
        btnAPP.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                cid = TFid.getText();
                amount = Integer.parseInt(TFfuel.getText());

                if (amount<100000) {
                    tax = 10000;
                } else if (amount > 100000 && amount < 500000) {
                    tax = 110000;
                } else {
                    tax = 200000;
                }
                print();
            }
        });
    }

    public static void main(String[]args) {
        FUEL1 h = new FUEL1(null);
    } 
}

I tried using settext and gettext expecting that the contents of the textfield will be displayed in the text area

0

There are 0 answers