Yeah, say if it was .println("ff"+deliveryName); it would show "ff"
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Yeah, say if it was .println("ff"+deliveryName); it would show "ff"
Does it print BEFORE the user enters anything in the text field?
If you don't understand my answer, don't ignore it, ask a question.
public void deliveryWindow(){ JFrame newFrame = new JFrame("Delivery Details"); Container pane = getContentPane(); newFrame.setLayout(new FlowLayout()); newFrame.setSize(new Dimension(250, 250)); //newFrame.getContentPane().add(panel); newFrame.setLocation(300,300); newFrame.setSize(250,250); newFrame.setVisible(true); JButton submitButton = new JButton("submit"); newFrame.add(submitButton); ButtonEventHandler handler = new ButtonEventHandler(); submitButton.addActionListener(handler); JPanel name = new JPanel(); JLabel nameLabel = new JLabel(); nameLabel.setText("Name :"); JTextField nameField = new JTextField(15); name.add(nameLabel); newFrame.add(nameLabel); newFrame.add(nameField); } private class ButtonEventHandler implements ActionListener { public void actionPerformed(ActionEvent e) { name1=nameField.getText(); if (e.getActionCommand().equals("submit")) { JOptionPane.showMessageDialog(null,"Your name is" + name1 ,"Message",JOptionPane.INFORMATION_MESSAGE); } else JOptionPane.showMessageDialog(null,"Nothing"); }}
Now Run this Code.. The Mistake you did is the place where u assigned the value of Text to the String deliveryName.. You should place it in the ActionPerformed Method..
@vigneshwaran
Which do you think is a good way to help a beginner learn to solve programming problemns?
Find his problem and give him the solution. AKA spoonfeeding
or
Help the OP find what is causing the problem and work with to help him find the solution
If the OP is given the solution and not taught how to debug his code, how will he become a better programmer?
If you don't understand my answer, don't ignore it, ask a question.
@ Norm : What's the Mistake i did?
--- Update ---
I just corrected the mistake he did. Not Spoonfeeded.
Sorry, you gave him the answer without helping him debug the code and find what the problem was = spoon feeding.
If you don't understand my answer, don't ignore it, ask a question.
vigneshwaran (December 1st, 2012)
Oh ok ok.. I'm new to here. I should let him solve. Anyway. Thanks 4 ur reply
What I try to do is to help the OP find the problem and solve it. That takes a few more steps and time.I should let him solve
If you don't understand my answer, don't ignore it, ask a question.