I'm not too familiar with java, but I was wondering if someone could help me, I have a form with three buttons on it. All I want to do Is call a function when one of the buttons is clicked.
I can't seem to find any examples of ActionListener for AWT that's NOT an applet(all examples i've found are applets).
Code someone take a look at my code and tell me how to make onclick events for my buttons. For example when the button called "Send" is selected, change the text field "Email" to say "Email Me"(or anything for that matter)
I work in an environment where the computers all have java 1.1. So I can't use the Swing classes.
Thanks in advance.
Here is my code:
import java.util.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class rvtDamon
{
public static void main(String args[]) {
//define layout manager
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
//define buttons
Button bSend = new Button("Send"
Button bBrowse = new Button("Browse"
Button bQuit = new Button("Quit"
//define the textfields
TextField tEmail = new TextField();
TextField tFile = new TextField();
//define the label
Label lblEmail = new Label("Email:"
Label lblFile = new Label("File:"
//create the frame(GUI)
Frame f = new Frame("RVT Damon"
f.setLayout(gridbag);
//add the email label
c.gridx = 0;
c.gridy = 0;
gridbag.setConstraints(lblEmail, c);
f.add(lblEmail);
//add the email textfield
c.gridx = 0;
c.gridy = 1;
c.ipadx = 300;
c.gridwidth = 3;
gridbag.setConstraints(tEmail, c);
f.add(tEmail);
c.ipadx = 0;
c.gridwidth = 1;
//add the file label
c.gridx = 0;
c.gridy = 3;
gridbag.setConstraints(lblFile, c);
f.add(lblFile);
//add the file textfield
c.gridx = 0;
c.gridy = 4;
c.ipadx = 300;
c.gridwidth = 3;
gridbag.setConstraints(tFile, c);
f.add(tFile);
c.ipadx = 0;
c.gridwidth = 1;
//add the browse button
c.gridx = 3;
c.gridy = 4;
gridbag.setConstraints(bBrowse, c);
f.add(bBrowse);
//add the Send Button
c.gridx = 2;
c.gridy = 5;
gridbag.setConstraints(bSend, c);
f.add(bSend);
//add the quit button
c.gridx = 3;
c.gridy = 5;
gridbag.setConstraints(bQuit, c);
f.add(bQuit);
f.pack();
f.show();
}
}
I can't seem to find any examples of ActionListener for AWT that's NOT an applet(all examples i've found are applets).
Code someone take a look at my code and tell me how to make onclick events for my buttons. For example when the button called "Send" is selected, change the text field "Email" to say "Email Me"(or anything for that matter)
I work in an environment where the computers all have java 1.1. So I can't use the Swing classes.
Thanks in advance.
Here is my code:
import java.util.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class rvtDamon
{
public static void main(String args[]) {
//define layout manager
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
//define buttons
Button bSend = new Button("Send"
Button bBrowse = new Button("Browse"
Button bQuit = new Button("Quit"
//define the textfields
TextField tEmail = new TextField();
TextField tFile = new TextField();
//define the label
Label lblEmail = new Label("Email:"
Label lblFile = new Label("File:"
//create the frame(GUI)
Frame f = new Frame("RVT Damon"
f.setLayout(gridbag);
//add the email label
c.gridx = 0;
c.gridy = 0;
gridbag.setConstraints(lblEmail, c);
f.add(lblEmail);
//add the email textfield
c.gridx = 0;
c.gridy = 1;
c.ipadx = 300;
c.gridwidth = 3;
gridbag.setConstraints(tEmail, c);
f.add(tEmail);
c.ipadx = 0;
c.gridwidth = 1;
//add the file label
c.gridx = 0;
c.gridy = 3;
gridbag.setConstraints(lblFile, c);
f.add(lblFile);
//add the file textfield
c.gridx = 0;
c.gridy = 4;
c.ipadx = 300;
c.gridwidth = 3;
gridbag.setConstraints(tFile, c);
f.add(tFile);
c.ipadx = 0;
c.gridwidth = 1;
//add the browse button
c.gridx = 3;
c.gridy = 4;
gridbag.setConstraints(bBrowse, c);
f.add(bBrowse);
//add the Send Button
c.gridx = 2;
c.gridy = 5;
gridbag.setConstraints(bSend, c);
f.add(bSend);
//add the quit button
c.gridx = 3;
c.gridy = 5;
gridbag.setConstraints(bQuit, c);
f.add(bQuit);
f.pack();
f.show();
}
}