Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action Listeners

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
US
Hello all I'm new to Java.
Can somebody post a snippet(example) of adding a mouse action listner to a jscrollpane in an application. I struggled with this for an hour last night and its driving me nuts.

 
Here is a code for a test applet that implaments an action listener. The applet may not work by itself but should with minor modification.
Good luck
-Wiszh

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

public class TestApplet extends Applet implements ActionListener {
private Button btSubmit = new Button("Submit");
private TextField txtExt = new TextField(4);
private TextField txtTopic = new TextField();

public void actionPerformed(ActionEvent e) {
//if sumit button clicked
if (e.getActionCommand().equals("Submit"))
//do some stuff
}

public void init() {
super.init();
try {
setName("TestApplet");
setLayout(null);
setSize(426, 320);
add(btSubmit, "btSubmit");
btSubmit.addActionListener(this);
add(txtExt);
add(txtTopic);
}

public static void main(java.lang.String[] args) {
MakeReservation applet = new MakeReservation();
java.awt.Frame frame = new java.awt.Frame("Complete Room Reservation");

frame.add("Center", applet);

applet.init();
applet.start();
frame.pack();
frame.setSize(450, 350);
frame.show();
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top