Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 29th, 2006, 9:15 PM   #1
javaN00b
Newbie
 
Join Date: Mar 2006
Posts: 2
Rep Power: 0 javaN00b is on a distinguished road
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 9:30 PM.
javaN00b is offline   Reply With Quote
Old Mar 29th, 2006, 9:29 PM   #2
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
public void actionPerformed(ActionEvent e) {
	ta1.setText(tf1.getText() + "\n" + ta1.getText());
	tf1.setText("");
}
Please put your code inside CODE tags from now on.
titaniumdecoy is offline   Reply With Quote
Old Mar 29th, 2006, 9:31 PM   #3
javaN00b
Newbie
 
Join Date: Mar 2006
Posts: 2
Rep Power: 0 javaN00b is on a distinguished road
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.
javaN00b is offline   Reply With Quote
Old Mar 29th, 2006, 9:45 PM   #4
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
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
Mjordan2nd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:49 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC