hey everone!
i have a little problem with this program i wrote:
class uu {
public static void main(String args[]){
new u();
}
}
import static java.lang.System.out;
import javax.swing.*;
import java.util.Scanner ;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class u extends JFrame implements ActionListener{
JTextField TextFieldText1 = new JTextField(10);
JTextField TextFieldText2 = new JTextField(10);
JTextField TextFieldText3 = new JTextField(10);
JLabel label1 = new JLabel("type in name, address and money");
JLabel label2 = new JLabel("click finish to finish");
JLabel label3 = new JLabel("or addUser to add an account");
JButton finishButton = new JButton("finish");
JButton addUserButton = new JButton("addUser");
public u(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
setLayout(new FlowLayout()) ;
add(TextFieldText1);
add(TextFieldText2);
add(TextFieldText3);
add(label1);
add(label2);
add(label3);
add(finishButton);
finishButton.addActionListener(this);
add(addUserButton);
addUserButton.addActionListener(this);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==addUserButton){
TextFieldText1.setEnabled(false);
TextFieldText2.setEnabled(false);
TextFieldText3.setEnabled(false);
new u(); new uuu();
}else{
TextFieldText1.setEnabled(false);
TextFieldText2.setEnabled(false);
TextFieldText3.setEnabled(false);
new uuu();
}
}
}
import javax.swing.*;
import java.util.Scanner ;
import java.awt.FlowLayout;
class uuu extends u {
public uuu(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
setLayout(new FlowLayout()) ;
add(new JLabel(TextFieldText1.getText()));
add(new JLabel(TextFieldText2.getText()));
add(new JLabel(TextFieldText3.getText()));
pack();
setVisible(true);
}
}
when i execut it and click any button it just made another u class and never went to uuu.
thankyou if you can help me