add event listener.
____________
http://reader.imagero.com the best java image reader.
> > How can I send information about event from one object of one class to
> > another (belongs to another class)?
[quoted text clipped - 3 lines]
>
> http://reader.imagero.com the best java image reader.
Some example?
It looks like....
(1)Main class
//first file
public class MainFrame extends JFrame
{
...
public MainFrame()
{
...
TreePanel treePanel = new TreePanel();
...
}
...
public readEvent()
{
//here I want listen for an event
}
...
}
// (2) second file
public class TreePanel extends JPanel
{
...
prublic sendEvent()
{
//here I want to send event to first class
....
}
...
}
ak - 26 Jan 2004 11:23 GMT
----- Original Message -----
From: "Jacek Janiszewski" <jj3@gazeta.pl>
Newsgroups: comp.lang.java.gui
Sent: Monday, January 26, 2004 11:12 AM
Subject: Re: How redirect event between two public class?
> > > How can I send information about event from one object of one class to
> > > another (belongs to another class)?
[quoted text clipped - 5 lines]
>
> Some example?
//simple example with ActionListener, you can use other listeners (or write
your own)
public class MainFrame extends JFrame implements ActionListener {
//implements ActionListener
public void actionPerformed(ActionEvent e) {
//do something with event
}
public static void main(String [] args) {
MainFrame mf = new MainFrame();
TreePanel tp = new TreePanel();
tp.setActionListener(mf);
}
}
//only one ActionListener for simplicity - you can use Vector or
EventListenerList
public class TreePanel extends JPanel {
ActionListener listener;
public void setActionListener(ActionListener listener) {
this listener = listener;
}
public void sendEvent(ActionEvent ae) {
listener.actionPerformed(ae);
}
}
____________
http://reader.imagero.com the best java image reader.