The Artima Developer Community
Sponsored Link

Java Answers Forum
Create dialog....

6 replies on 1 page. Most recent reply: Sep 26, 2003 7:30 AM by Pratheeba

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Pratheeba

Posts: 11
Nickname: pratheeba
Registered: Sep, 2003

Create dialog.... Posted: Sep 25, 2003 1:51 PM
Reply to this message Reply
Advertisement
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....


zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: Create dialog.... Posted: Sep 25, 2003 3:04 PM
Reply to this message Reply
You can develop your own dialog by extending the JDialog and putting inside all the labels, texts and actions you need.

Pratheeba

Posts: 11
Nickname: pratheeba
Registered: Sep, 2003

Re: Create dialog.... Posted: Sep 25, 2003 3:28 PM
Reply to this message Reply
Hi, Thanks for u'r reply...Can u give an example...

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Create dialog.... Posted: Sep 26, 2003 12:44 AM
Reply to this message Reply
		JDialog dialog = new JDialog(new Frame(),
		                              "Click a button",
		                              true);
		 dialog.setContentPane(new JButton("Click Me"));
		 dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		 dialog.addWindowListener(new WindowAdapter() {
		     public void windowClosing(WindowEvent we) {
		         System.exit(0);
		     }
		 });
		 dialog.setSize(100,50);
		 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      	 dialog.setLocation((screenSize.width - 100) / 2, (screenSize.height - 50) / 2);
		 dialog.setVisible(true);
 

Pratheeba

Posts: 11
Nickname: pratheeba
Registered: Sep, 2003

Re: Create dialog.... Posted: Sep 26, 2003 6:46 AM
Reply to this message Reply
Hi,Here is my code what i did...But it says adding container to parent itself....I still can't know why it is...sorry to ask again and again....Thanks...

JTextField tName= new JTextField(15);
JLabel lName = new JLabel("Enter the Name")

JFrame f = new JFrame("Creating PriceSheet");
JDialog dialog = new JDialog(f);

f.getContentPane().add(lName,BorderLayout.EAST);
f.getContentPane( ).add(tName,BorderLayout.WEST);
dialog.setContentPane(f);

dialog.setDefaultClos eOperation( JDialog.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent we)
{ System.exit(0);
}
});

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setLocation((screenSize.width - 100) / 2, (screenSize.height - 50) / 2);
dialog.setVisible(true);

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Create dialog.... Posted: Sep 26, 2003 7:01 AM
Reply to this message Reply
		JTextField tName= new JTextField(15);
		JLabel lName = new JLabel("Enter the Name");
 
		JFrame f = new JFrame("Creating PriceSheet");
		f.getContentPane().setLayout(new BorderLayout());
		JDialog dialog = new JDialog(f);
 
		f.getContentPane().add(lName,BorderLayout.WEST);
		f.getContentPane( ).add(tName,BorderLayout.EAST);
		
		dialog.setContentPane(f.getContentPane());
 
		dialog.setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE);
		dialog.addWindowListener(new WindowAdapter()
		{public void windowClosing(WindowEvent we)
		{ System.exit(0);
		}
		});
		
	    dialog.setSize(300,50);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		dialog.setLocation((screenSize.width - 300) / 2, (screenSize.height - 50) / 2);
		dialog.setVisible(true);
 
//check
//I did dialog.setContentPane(f.getContentPane());
//Instead of dialog.setContentPane(f);

Pratheeba

Posts: 11
Nickname: pratheeba
Registered: Sep, 2003

Re: Create dialog.... Posted: Sep 26, 2003 7:30 AM
Reply to this message Reply
Thanks a lot...

Flat View: This topic has 6 replies on 1 page
Topic: How do I convert a file to a unicode encoding?? Previous Topic   Next Topic Topic: setDate error

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use