Comment

ligami
response,
September 13, 2007 at 1:14 PM

thanks for the help. I am a new java student and have found the example helpful.

how do I make a text area respond to the button's event this is what i have



import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class appTrial extends Applet{
public void init(){
resize(400,200);
TextField text1=new TextField(30);
Label l1=new Label("Enter Age >");
Panel p1=new Panel();p1.setLayout(new FlowLayout(FlowLayout.LEFT));
p1.add(l1);
p1.add(text1);

TextField text2=new TextField(30);
Label l2=new Label("Total Price >");
Panel p2=new Panel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT));
p2.add(l2);
p2.add(text2);

Button b1=new Button("Done");
b1.addActionListener(new ButtonHanler);
Button b2=new Button("Clear");
b2.addActionListener(new ButtonHndler);
Panel p3=new Panel();
p3.add(b1);
p3.add(b2);

Panel p4=new Panel();
p4.setLayout(new FlowLayout(FlowLayout.LEFT));

Panel main=new Panel();
main.setLayout(new GridLayout(4,2));
main.add(p4);
main.add(p1);
main.add(p2);
main.add(p3);
add(main);
}
}
public class MyActionListener implements ActionListener {
public String b1= "OK";
public String b2= "CANCEL";

public void actionPerformed (ActionEvent ae) {
Object source = ae.getSource();

/* Is it a JButton??? */
if (source instanceof JButton) {
JButton bu = (JButton)source;

/* Which JButton is it? */
String cmd = bu.getActionCommand();
if (cmd==b1){

} else
if (cmd==b2) {

}
}
}

}

View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Server Faces Questions

Review
Review  Friends please help e on this How to write java code to display the next question onclicking review button 

General

Events
; In this section, you will learn how to handle events in Java awt. Events... with the consumption of the events by the system once a listener is notified. Consumption only... Listener interface as Events subclass the AWTEvent class. However, PaintEvent 

Swing AWT

GUI
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml 

Java Interview Questions

Java listener
Java listener  What is source and listener 

Java Beginners

java gui
java gui   friends... good day.. i have doubt in java gui. ? i created 1 java gui application. That has two text fields jtext1,jtext2. case: user... use from the action listener of jtext1 to happen like 

Java Beginners

threads and events
threads and events  Can you explain threads and events in java for me. Thank you.   Java Event Handling Java Thread Examples 

Java Interview Questions

Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class 

Java Beginners

Java Printer Listener - Java Beginners
Java Printer Listener  I want some programs to make listener for all... for java applications i want printer listener for all applications in the system... for more information. http://www.roseindia.net/java/example/java/swing 

Free Magazine

Tips and Tricks
Tips and Tricks           Send data from database in PDF file as servlet response This example retrieves data from MySQL and sends response to the web browser 

Java Beginners

Text change and click events
Text change and click events  Create user login form and apply textchange and click events in java 

Java Beginners

GUI Interface - Java Beginners
GUI Interface  Respected sir, please send me the codimg of basic... and multiplication. But use classes javax swing java awt java awt.event no other...); clearButton.addActionListener(new ClearListener()); //--- One listener 

Free Magazine

Tips & Tricks
Tips & Tricks           Splash Screen in Java 6.0 Splash screens are standard part of many GUI applications to let the user know about starting 

Swing AWT

Java GUI
Java GUI  1) Using Java GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image 

Java Interview Questions

Java GUI
Java GUI  difference between swing and applet 

Java Beginners

Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES 

Java-Tutorials

Item Events in Java
Item Events in Java      ... events in java. This demonstrates that the event generated when you select an item from the group of the items. This program demonstrates how the item events 

Java Beginners

What are events? Explain how Event handling in Java?
What are events? Explain how Event handling in Java?  What are events? Explain how Event handling in Java?   Hi, The Events are the integral part of the java platform. Sometimes we want one object to perform shorten 

Java Interview Questions

Interview Tips - Java Interview Questions
Interview Tips  Hi, I am looking for a job in java/j2ee.plz give me interview tips. i mean topics which i should be strong and how to prepare. Looking for a job 3.5yrs experience 

General

How to handle the text using Key Listener Interface
How to handle the text using Key Listener Interface       In this section, you will learn how to handle the text using the key events on the Java Awt component. All the key events 

Free Magazine

Tips and Tricks
Tips and Tricks        ... in Java Java provides a lot of fun while programming. This article shows you how... and keyboard related operation through java code for the purposes of test automation, self 

Java Beginners

Server_Gives_Null_Response
port(6066). I have one client class which is in different java project. My... for connection at port 6066. When i run my client class form different java... at port 6066. My Problem is that when i send response from server (port 6066 

Framework Questions

getOutputStream() has already been called for this response
called for this response. here is my jsp code: <%@ page import...,com.zyom.webclient.util.MozartConstants"%> <%@ page language="java" pageEncoding..." > Review Sales Regions, Roles Mapped to Regions 

Java Beginners

request header and response - Java Beginners
 

Java Beginners

Java Gui - Java Beginners
Java Gui  HOW TO ADD LINK LABELS IN JAVA PROGRAMMES 

Java Beginners

Waiting for ur quick response
Waiting for ur quick response  Hi, I have two different java... to run it java A The output is: Hai This part is completed. Now i ll go... have to run it java A Now the output is: Hello Now i want to get 

Java-Tutorials

Java - Event Listeners Example in Java Applet
listener is the feature of java that handles the several events for the several... Java - Event Listeners Example in Java Applet  ...*; package. So, to use the events handling in your application import 

Java Beginners

Java GUI - Java Beginners
Java GUI  How to use JTray in java programme?  Hi friend, JTrayIcon jtc= new JTrayIcon(image); // jPopupMenu is a javax.swing.JPopupMenu jtc.setRightClickTarget(jPopupMenu); jtc.show(); Thanks 

Java3D Questions

Java GUI - Java3D
Java GUI  1) Using Java GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image 

Java Beginners

Convert the code to GUI
Java GUI Class Example  Java GUI Class Example 

Java Beginners

Convert the code to GUI
GUI Java JSP application  GUI Java JSP application 

Java Beginners

Convert the code to GUI
Java and GUI application Example  Java and GUI application Example 

Java Beginners

java gui - Java Beginners
java gui  i have to create dynamically databse,table, and number of field..inside that field dynamically data can be entered with type of variable..after entering all the dat in different form field label,i should have a button 

Java Beginners

GUI problem - Java Beginners
GUI problem  how to write java program that use JTextField to input data and JTextField to display the output when user click Display Button??  Handle the actionPerformed event for JButton and try doing something like 

Java Beginners

java gui-with jscroll pane
java gui-with jscroll pane  Dear friends.. I have a doubt in my gui application. I developed 1 application. In this application is 1 Jscrollpane of height 600 and width 400. Normally it is showing 200 height and 400 width 

Java Beginners

java gui-with jscroll pane
java gui-with jscroll pane  Dear friends.. I have a doubt in my gui application. I developed 1 application. In this application is 1 Jscrollpane of height 600 and width 400. Normally it is showing 200 height and 400 width 

Java Beginners

GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event... world and like it alot. I was wondering where can I go to learn more about java 

Java Beginners

Gui Interface - Java Beginners
Gui Interface  hi I have two seperate interfaces in the same projects . my question is how can I access this interface using a jbutton (i.e jbutton = next where next points to another interface addCourse.java) What would 

Java Beginners

java gui database - Java Beginners
java gui database  I have eight files. Each file has exactly same... the data on command line but I do not know how to display the same using java gui. Could anybody help me. Thanks. Shah 

Servlets-Tutorials

Java Servlet : Http Response Headers
Java Servlet : Http Response Headers In this tutorial, you will learn how to Http Response Headers works in java servlet. Http Response Headers : Web server sends response with one or more response headers including the document 

Java Beginners

GUI - Java Beginners
GUI testing  GUI testing in software testing  HiNow, use the code and get the answer.import javax.swing.*;public class DemoTryCatchDialog...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event 

Java Beginners

Java GUI code
Java GUI code  Write a GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows: Amount deposited: 80000.00 Years: 15 Interest rate: 7.75 Total Amount: Hint** to solve this problem 

Applet Questions

Java GUI - Applet
Java GUI  HELLO, i am working on java chat server, i add JFrame and make GUI structure by draging buttons and labels, now i want to insert... but not resolve my prob. dear friend, i add JFrame Form in java package and put 

Java Beginners

Convert the code to GUI
How to create GUI application in Java   How to create GUI application in Java 

Java Beginners

Chat in Java wih GUI
Chat in Java wih GUI  Welcome all >> << how is everybody >< i wanna Chat program in java server & client thanks 

Eclipse Plugins

Jigloo SWT/Swing GUI Builder
Jigloo SWT/Swing GUI Builder         CloudGarden's Jigloo GUI Builder is a plugin for the Eclipse Java IDE and WebSphere Studio, which allows you to build and manage 

JSP Servlet Questions

XML response correct in broser but incorrect in Java
XML response correct in broser but incorrect in Java  Firs of all I want to say that I was able to read XML response from URL. Thank you for this and many other helps. I read and printed the response (code below) but the result 

Development process Questions

HELP! Design Review & Risk Management topics (in Java projects) required - Development process
HELP! Design Review & Risk Management topics (in Java projects) required  Hi, I have to take 2 one hour sessions on the following topics: * Project Design Review * Project Risk Management Can you please recommend any 

Servlets

Response Filter Servlet Example
Response Filter Servlet Example       This Example shows how to use of response filter in  Java Servlet. Filter reads own initial parameters and adds its value 

XML Tutorials

Locating the Notified Events
Locating the Notified Events      ... appropriate messages according to the events generated while parsing a xml document. ...; </issued-items> </Employee-detail> Here is Java File 

Java Beginners

GUI - Java Beginners
links: http://www.roseindia.net/tutorial/java/swing/navigatedata.html http://www.roseindia.net/java/example/java/swing/add_edit_and_delete_employee_inf.shtml 

Java Beginners

Java scroll pane-java GUI
Java scroll pane-java GUI  Dear friends.. Very Good morning. I have a doubt in my gui application. Take ex:- My gui application has 1 Jscrollpane of height 600 and width 400. normally it is showing 200 height and 400 width 

Java Beginners

Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans 

Java Beginners

Convert the code to GUI
Java Code to GUI   can any one convert My code to GUI code 

Java Beginners

Component gui - Java Beginners
Component gui  Can you give me an example of Dialog in java Graphical user interface?  Hi friend, import javax.swing.*; public...://www.roseindia.net/java/example/java/swing/ Thanks 

Java Beginners

How To Insert A New Record to MS Access table database in GUI
, I've been working on the actionPerformed part of my java application... on the actionPerformed events. The problem I'm having is that when the user clicks... at this step. For simplicity, I am including only the add button listener and action 

Java Beginners

java GUI program - Java Beginners
java GUI program  java program that creates the following GUI, when user enter data in the textfield, the input will be displayed in the textarea...://www.roseindia.net/java/ Thanks. Amardeep 

Java Beginners

GUI - Java Beginners
 

Java Beginners

Gui - Java Beginners
 

Java Beginners

GUI - Java Beginners
 

Java Beginners

Java GUI IndexOf - Java Beginners
Java GUI IndexOf  Hello and thank you for having this great site. Here is my problem. Write a Java GUI application called Index.java that inputs several lines of text and a search character and uses String method indexOf 

Java Beginners

Java GUI Program - Java Beginners
Java GUI Program  How is the following program supposed to be coded? Write an application that prompts the user to enter the radius of a circle...://www.roseindia.net/java/ Thanks. Amardeep 

Java Beginners

how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java 

Java Beginners

Magic Matrix in GUI
Magic Matrix in GUI  I want program in java GUI contain magic matrix for numbers 

Java Beginners

Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application 

Java Beginners

MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java  i wanna MultiClient-server tcp-ip with GUI in java 

Java Beginners

MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java  i wanna MultiClient-server tcp-ip with GUI in java 

Java Beginners

GUI testing/software testing - Java Beginners
GUI testing/software testing  how to create a GUI testing/software testing module in java 

Java Beginners

Rental Code GUI - Java Beginners
Rental Code GUI  dear sir... i would like to ask some code of java GUI form that ask the user will choose the menu to input Disk #: type: title: record company: price: director: no. of copies 

Free Programming books

Java server Faces Books
for GUI components, component state, and input events. These classes... Java server Faces Books         Java server Faces 

Struts Questions

pls review my code - Struts
pls review my code  When i click on the submit page i am getting a blank page Pls help me. thanks in advance. public ActionForward execute..., HttpServletResponse response) throws ServletException,IOException{ LOGINForm 

Struts Questions

pls review my code - Struts
pls review my code  Hello friends, This is the code in struts. when i click on the submit button. It is showing the blank page. Pls respond soon..., HttpServletRequest request, HttpServletResponse response) throws 

Struts 2 Tutorials

Access Request and Response
the request and response object in struts 2 application. To access the request... and to access the response object, use the ActionContext or implement... action class. Accessing the request and response object, you need a struts.xml 

Java Beginners

Java GUI code- creating a circle
Java GUI code- creating a circle  My assignment is to write a program...; //GUI components JLabel lClx, lCly, lCircumrx, lCircumry, lRadius... //constructor public CircleGUI() { //create GUI lClx 

Java Beginners

Java GUI problem with linklists and administration - Java Beginners
Java GUI problem with linklists and administration  Hi, I'm having trouble making a GUI interface in java, where a list of names are displayed using a jList. The java program should be able to allow the user to add names, remove 

Java Beginners

i need a quick response about array and string...
i need a quick response about array and string...  how can i make a dictionary type using array code in java where i will type the word then the meaning will appear..please help me..urgent 

Java Beginners

Convert this code to GUI - Java Beginners
Convert this code to GUI  I have written this.i need to convert the following code to GUI:- import java.awt.*; import java.applet.*; import...); } }  hi friend, We have convert your code into GUI 

Struts Questions

Pls review my code - Struts
Pls review my code  Hello friends, this is my code in struts action class this page contains checkboxes and radiobuttons also. when i enter..., HttpServletRequest request, HttpServletResponse response, String String 

Java Beginners

Writing a GUI program - Java Beginners
Writing a GUI program  Hello everyone! I'm trying to write a program that has a text field for input, two buttons and the output text area. A user... to write the code for the GUI. Could anyone please help?  Hi Friend 

Programming Tutorials

Dojo Tool tips
Dojo Tool tips           In this section, you will learn about the tool tips and how to developed it in dojo.  Tool tips :  This is a GUI 

Programming Tutorials

Dojo Tool tips
Dojo Tool tips           In this section, you will learn about the tool tips and how to developed it in dojo.  Tool tips :  This is a GUI 

Java Beginners

How to convert this Java code into GUI?
How to convert this Java code into GUI?   import java.util.Scanner; public class StudentMarks { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks 

Java-Tutorials

Event Handling In Java
Event Handling In Java In this section you will learn about how to handle events in Java. Events in any programming language specifies the external effects.... For example, there is a Listener named ActionListener handles the events 

Java Beginners

GUI component
GUI component  How can a GUI component handle its own events 

JDBC Questions

Accessing Ms access data in JAVA GUI Envi.
Accessing Ms access data in JAVA GUI Envi.  Q.How to insert data into ms access data in java using swing ? Q.How to slove (access denided ("java.lang.RuntimePermission" "accessClassInPackage.sun.jdbc.odbc")" these exception 

Java Beginners

how to save a gui form in core java
how to save a gui form in core java  please help me i am java beginner how to save a jframe containing jtable and panels in java thank you 

XML Questions

turn the GUI(java class) into XML - XML
turn the GUI(java class) into XML   Hi im trying to turn the GUI(java class) into XML ,means in my gui one combobox is there if i select one... GUI that combobox contains different types of maps.If i select one map name 

Applet Questions

Java gui program for drawing rectangle and circle
Java gui program for drawing rectangle and circle   how to write java gui program for drawing rectangle and circle? there shoud be circle and rectangle button, check box for bold and italic, and radio button red,green and blue 

Java Server Faces

Phase Listener
and phase events are fired during the start and end of each phase. We can capture phase events by defining a Phase Listener class as below. The class should...Phase Listener       

Java Beginners

Gui plz help
Gui plz help   Create a Java application that would allow a person to practice math (either addition, subtraction, multiplication or division... far. so basically what i did is i used the java palletes to make a application 

Java Beginners

how to handle action events in case of more than one JFrame
how to handle action events in case of more than one JFrame   I have downloaded a snake game project from the internet, initially this project contains three java files namely 1. Engine.java 2. Snake.java 3. Gameoard.java when i 

Java Beginners

Regarding GUI Applications
GUI Applications  How to create a save and open jmenu item in java desktop application.   Here is a simple JMenuItem example in java swing through which you can perform open and save operations on File. import 

Ajax

Raju?s GUI-API
possible for traditional GUI Platforms such as Java/Swing or Windows/VC++. Read... Raju?s GUI-API       Raju?s GUI-API Ajax reusable GUI Classes are based on ?patent pending? inventions 

Java-Tutorials

Catching Exceptions in GUI Code - Java Tutorials
.style1 { text-align: center; } Catching uncaught exception in GUI In this section, we will discuss how to catch uncaught exceptions in GUI. Lets see... javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; public class Gui 

Ajax Questions

how can add new line character into ajax response for java
how can add new line character into ajax response for java   i want to populated brand drop-down list and state drop-down list by changing on country drop-down list i mean according to country name there will be change in state 

Ajax Questions

how can add new line character into ajax response for java
how can add new line character into ajax response for java   i want to populated brand drop-down list and state drop-down list by changing on country drop-down list i mean according to country name there will be change in state 

Free Magazine

Tips & Tricks
Tips & Tricks          Here are some basic implementations of java language, which you would... screen button on the keyboard, same way we can do it through java programming 

Java Beginners

bank account gui
; Transaction>(); I already done with the GUI i just need the code to make the button...."; } } For more information, visit the following link: http://www.roseindia.net/tutorial/java 

Java Beginners

Regarding GUI Applications
jmenu item in java desktop application  How to create a save and open jmenu item in java desktop application.   Here is a simple JMenuItem example in java swing through which you can perform open and save operations 

Java Beginners

Regarding GUI Applications
save and open jmenu item  How to create a save and open jmenu item in java desktop application.   Here is a simple JMenuItem example in java swing through which you can perform open and save operations on File 

Java Beginners

Regarding GUI Applications
open jmenu item in java  How to create a save and open jmenu item in java desktop application.   Here is a simple JMenuItem example in java swing through which you can perform open and save operations on File. import 

Advertisements Advertisements
 

 

 

DMCA.com