Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2003, 02:49 PM
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using JDialog to get values from user

Hi,
 I am new to JFC. When user press ok button it has to popup one JDialog, which is asking as follows...

Enter the product name ---------------
Enter the product code ---------------
Enter the accountno ---------------

Note: Here i wants to add 3label and 3 TextField in the same Dialog... I saw some example it shows to get one value using InputDialog....But i want to put all in same dialog...


Thanks....


 
Old October 9th, 2003, 02:30 AM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to secret_friend
Default

hi pratheeba!
this is the code u wanted.
u can ask any doubt .
mail to me directly ,
dont use this form i may not be checking this regularly
contact me for any help .
my mail id: way_to_victory@kongu.ac.in

              urs
              kk


//MainFrame.java
import javax.swing.*;
import java.awt.event.*;


public class MainFrame extends JFrame

implements ActionListener

{

   public MainFrame()
       {
       super("Dialog Based Application");
       //settings for JFrame
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setBounds(100,100,400,330);
       getContentPane().setLayout(null);

       //JButton Settings
       click=new JButton("Click me");
       click.setBounds(150,130,100,40);
       click.addActionListener(this);




       //adding controls to JFrame

       getContentPane().add(click);



       show();
        }



       public void actionPerformed(ActionEvent ae)
          {




           JButton ok=new JButton("ok");
          ok.setBounds(120,170,70,40);
          ok.addActionListener(new ActionListener(){

             public void actionPerformed(ActionEvent e)
                          {

                          //add ur code here to manipulate text field values

                          inputbox.setVisible(false);

                          }

                          }

                          );



          inputbox=new JDialog(MainFrame.this,true);


          inputbox.setTitle("Enter Inputs");
          inputbox.getContentPane().setLayout(null);
          inputbox.setBounds(150,150,300,250);



          lblname=new JLabel("Product Name");
          lblcode=new JLabel("Product Code");
          lblacc=new JLabel("Account Number");


          lblname.setBounds(20,20,120,40);
          lblcode.setBounds(20,70,120,40);
          lblacc.setBounds(20,110,120,40);


          inputbox.getContentPane().add(lblname);
          inputbox.getContentPane().add(lblcode);
          inputbox.getContentPane().add(lblacc);



          txtname=new JTextField("");
          txtcode=new JTextField("");
          txtacc=new JTextField("");


          txtname.setBounds(160,20,120,40);
          txtcode.setBounds(160,70,120,40);
          txtacc.setBounds(160,120,120,40);


          inputbox.getContentPane().add(txtname);
          inputbox.getContentPane().add(txtcode);
          inputbox.getContentPane().add(txtacc);
          inputbox.getContentPane().add(ok);








          inputbox.show();





          }

       public static void main(String[] args)
                {

                  new MainFrame();
                }



            public JButton click;
            public JDialog inputbox;
            public JLabel lblname;
            public JLabel lblcode;
            public JLabel lblacc;
            public JTextField txtname;
            public JTextField txtcode;
            public JTextField txtacc;
     }





Similar Threads
Thread Thread Starter Forum Replies Last Post
JDialog hoop_12 Java GUI 0 April 20th, 2006 11:56 AM
Jdialog tabbed panes nady Java GUI 0 April 11th, 2006 12:52 PM
New User having trouble with Zero Values AngelaR Pro VB 6 1 January 8th, 2006 09:15 PM
No text in Jdialog poojak16 Java GUI 2 May 23rd, 2005 02:26 AM
Titlebar on JDialog/JFrame raven983 Java GUI 4 May 7th, 2005 07:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.