Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2007, 05:18 PM
Member
 
Join Date: Jul 2007
Posts: 26
romina is on a distinguished road
I'm trying to add a separate dialog to a Java program...
I'm trying to add a separate dialog/window to a Java program that collects the user's information from three different text boxes.

I have looked at the sun tutorial, swing textbooks, and a graphic java text, but I'm still confused.

How do I layout the three textboxes and the four related labels in the dialog? And how do I get this information from the dialog/window and send it back to the main frame in a single string (e.g. textbox1+textbox2+textbox3)?
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 07:26 AM
Member
 
Join Date: Jul 2007
Posts: 40
trill is on a distinguished road
I recommend you start off with only one textbox and a label. After you complete it, experiment a bit with more labels and boxes..

Here is how you would add a JTextfield and a JLabel. Note you will still need to create a main class:
Code:
import java.awt.*; import java.awt.event; import javax.swing.*; public class YouClassNameHere extends JPanel{ private JLabel YourInputLabel; private JTextfield YourTextField; public YourClassNameHere(){ YourInputLabel = new JLabel("You write something here"); YourTextField = new JTextField(#); //where # is any number. Gives a size to the TextField. YourTextField.addActionListener(new TempListener());//this will tell the program that you want to interact with it. add (YourInputLabel); add(YourTextField); setPreferredSize(new Dimension(300,75)); setBackground (Color.yellow); } //Then just add a TempListener class. Inside this class, you might want //to define some variables, and perform some operations. }
As far as joining the inputs, you can do it this way
Code:
String String1 = new String("Hello"); String String2 = new String("World!"); String String3 = new String(String1 + " " + String2); //Creates a new String with the values of String1 and String2 System.out.println(String3);
Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hash table with separate chaining Java Tip java.lang 0 04-12-2008 10:42 PM
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 04:40 PM
Dialog typeface outside Java Dreen New To Java 1 11-19-2007 09:35 AM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 11:33 PM
Java Print Dialog Framework 1.7 levent Java Announcements 0 06-19-2007 07:07 PM


All times are GMT +3. The time now is 12:40 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org