Results 1 to 1 of 1
Thread: problem with getting new JFrames
- 02-09-2008, 12:46 PM #1
problem with getting new JFrames
hey everone!
i have a little problem with this program i wrote:
Java Code:class uu { public static void main(String args[]){ new u(); } }Java Code: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(); } } }when i execut it and click any button it just made another u class and never went to uuu.Java Code: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); } }
thankyou if you can help mehe who laughs last probabely just got the joke
Similar Threads
-
Handling Two JFrames
By hiranya in forum AWT / SwingReplies: 2Last Post: 11-05-2007, 07:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks