![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 2
Rep Power: 0
![]() |
PLS Help me in a very simple (noob) program about textfields and textareas.
Hi dudes first post here but I guess you'll see a lot of posts b4 I finish with my java course at uni. Anyways, I may be a leet in hardware ( Using car parts to cool proccessors has already destroyed my soscial life :pp) but when it comes to programming i'm a zero. Anywayz to my question. I got to make 3 simple programs this week for my java course.
In one of these programs i need to make an applet that has a text field on the top and a textarea on the bottom. You're supposed to type a name on the text field then press enter and the name transfers on the textarea. When you type a new name the name you typed 1st goes down 1 line and the new name is on the top. Simple huh? Well after torturing myself coding in jcreator for about 4 hours i came up with this little proggram:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class A3P3 extends Applet implements ActionListener {
TextField tf1 ;
TextArea ta1;
String s;
public void init() {
tf1=new TextField(10);
add(tf1);
tf1.addActionListener(this);
ta1=new TextArea(4,20);
add(ta1);
}
public void actionPerformed(ActionEvent e) {
s=e.getActionCommand();
tf1.setText("");
ta1.setText(s);
}
}The program works cool I compile it and run it and everything. The problem is I don't know how to make the string on the textarea to move down 1 line when a new word is typed on the textfield. Right now you just type a word on the text field , you press enter , the word is transfered to the text area but when you repeat the proccess the new word deletes the old one :/ . I want the old one to go down 1 line and the new to be on the top. So pls modify the program so It does that or I wont be the next Bill Gates and I'll go live on a cave hunting for food. English is not my native language so sorry If anything you read makes your eyes bleed. Last edited by javaN00b; Mar 29th, 2006 at 10:30 PM. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
public void actionPerformed(ActionEvent e) {
ta1.setText(tf1.getText() + "\n" + ta1.getText());
tf1.setText("");
} |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2006
Posts: 2
Rep Power: 0
![]() |
thanks for the ultra fast response , sorry for tags.
I compiled it it works.. how does it feel to do in 1 min stuff that take others hours to complete.. I'll use this thread for questions regarding future assigments instead of spamming new threads. |
|
|
|
|
|
#4 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Nah, unless it pertains to textfields and textareas, it's probably better all around if you just made a new thread.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|