take out the print of the textfield output when it is displayed in message box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parwaaz sandhu
    New Member
    • Mar 2013
    • 1

    take out the print of the textfield output when it is displayed in message box

    Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class  RetrieveDataFromTextFields{
    
        public static void main(String[] args){
        JFrame f=new JFrame();
        JLabel label1=new JLabel("Name: ");
        JLabel label2=new JLabel("Address: ");
        final JTextField text1=new JTextField(20);
        final JTextField text2=new JTextField(20);
        JButton b=new JButton("Submit");
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            String value1=text1.getText();
            String value2=text2.getText();
            JOptionPane.showMessageDialog(null,"Name is: "+value1+"\nAddress is: "+value2);
            }
        });
            JPanel p=new JPanel(new GridLayout(3,2));
            p.add(label1);
            p.add(text1);
            p.add(label2);
            p.add(text2);
            p.add(b);
            f.add(p);
            f.setVisible(true);
            f.pack();
        }
    }
    +++++++++++++++ ++++++++


    i want to take out the print of the textfield output when it is dispyd in message box
    Last edited by acoder; Mar 17 '13, 10:53 PM. Reason: Please use [code] tags when posting code
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What do you mean by "take out the print of the textfield output"?

    Comment

    Working...