By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,646 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,646 IT Pros & Developers. It's quick & easy.

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

P: 1
Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.awt.event.*;
  4. class  RetrieveDataFromTextFields{
  5.  
  6.     public static void main(String[] args){
  7.     JFrame f=new JFrame();
  8.     JLabel label1=new JLabel("Name: ");
  9.     JLabel label2=new JLabel("Address: ");
  10.     final JTextField text1=new JTextField(20);
  11.     final JTextField text2=new JTextField(20);
  12.     JButton b=new JButton("Submit");
  13.     b.addActionListener(new ActionListener(){
  14.         public void actionPerformed(ActionEvent e){
  15.         String value1=text1.getText();
  16.         String value2=text2.getText();
  17.         JOptionPane.showMessageDialog(null,"Name is: "+value1+"\nAddress is: "+value2);
  18.         }
  19.     });
  20.         JPanel p=new JPanel(new GridLayout(3,2));
  21.         p.add(label1);
  22.         p.add(text1);
  23.         p.add(label2);
  24.         p.add(text2);
  25.         p.add(b);
  26.         f.add(p);
  27.         f.setVisible(true);
  28.         f.pack();
  29.     }
  30. }
+++++++++++++++++++++++


i want to take out the print of the textfield output when it is dispyd in message box
Mar 17 '13 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
What do you mean by "take out the print of the textfield output"?
Mar 18 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.