473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

accessing a textfield

hi every one
i am new to java and object oriented programming.my problem is that i wanna acces a text field...in a frame i created a text area and a button.i want to populate textarea when the button is clicked..i know it is very simple to you but i have been struggling with this for hours.....below is the source code...
thanx in advance

----------------------
/*
* i am trying to populate a textfield or textarea when a button is clicked...
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.Button;
public class ForTestPurposesOnly extends GUIFrame
implements TextListener,ActionListener{
String msg=new String(" ");
int flag =0;
public ForTestPurposesOnly(){
super("Buttons And Text components together");
Button button=new Button("Click me!!!!");
button.addActionListener(this);
add(button,BorderLayout.SOUTH);
setSize(100,100);
setVisible(true);
TextField tf=new TextField();
tf.addTextListener(this);
add(tf,BorderLayout.NORTH);
pack();



}

public void actionPerformed(ActionEvent event){
if (event.getSource() instanceof Button){
System.out.println();

if (flag==0){
flag=1;
}
else{
flag=0;

}

}
}




public void textValueChanged(TextEvent event){
TextComponent src=(TextComponent)event.getSource();
if(flag==1){
src.setText("murtaza");
}
else{
src.setText("");
}

}







public static void main(String args[]){
new ForTestPurposesOnly();
}




}
Sep 3 '06 #1
0 1249

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: C. Armour | last post by:
Help me, I'm suffering! Situation: I have a load() function which loads a bunch of TextFields with values. There are TextListeners registered for each of these TextFields. Thus, changing the...
1
by: Veverita | last post by:
Hi there I'm hoping that someone can help me with a question I have about javascript syntax. I got an html page that uploads an image and some text field to a database. What I'd like to do...
1
by: Suresh | last post by:
How do I insert a char into the textfield on the keypress event of another textfield? I have two textboxes, "text1" and "text2". Important: "text1" is outside the table. "text2" is inside...
3
by: Sidney Linkers | last post by:
Hi, I'm trying to make a calculated text field in a query where the textvalue is being populated from multiple records. I already use a VBA function to loop through records and concatenate the...
3
by: Cah Sableng | last post by:
Hi all. I am new member of this group. I have a problem with currency formatter function I made. On onkeyup's method of a textfield I add function below: <snip> function formatCurrency(elm)...
9
by: learning | last post by:
Hi! Here's my situation: I have one textfield with one 'submit' button in PAGE1.PHP. When I click on the 'submit' button I am sent to PAGE2.PHP where I have a "switch" routine that checks...
2
jkmyoung
by: jkmyoung | last post by:
I was trying to create an applet with a TextField that would only accept an integer, and ignore any other keystrokes. Eg, if a user typed in an 'f' into the field, the TextField should ignore it, and...
0
by: adamselearning | last post by:
Hi... I've followed Colin Moock's AS3 notes to create a VirtualPet I've got it working from the code at: http://www.adobe.com/devnet/actionsc...n_moock_f6.pdf ...but am now trying to add a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.