View Single Post
  #2 (permalink)  
Old 08-07-2007, 07:26 AM
trill trill is offline
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.
Reply With Quote