You are not logged in.
Hi,
As the title implies, I need a JPanel to fire an event, any event will do, it is embedded into an interface and needs to signal the parent component that it is ready with data. The JPanel is to collect data and is to have a JButton on it, firing an event that the listener can capture and react to by extracting the data from the JPanel.
JInternalFrames have this:
private void doFireAnEvent()
{
// fire an event the listener can hear
this.fireInternalFrameEvent(InternalFrameEvent .INTERNAL_FRAME_CLOSING);
}
The "parent" listens with a frame listener
myThing.addInternalFrameListener(new InternalFrameListener()
{
public void internalFrameClosing(InternalFrameEvent e)
{
// capture the fired event here
}
public void internalFrameClosed(InternalFrameEvent e)
{
}
public void internalFrameOpened(InternalFrameEvent e)
{
}
public void internalFrameIconified(InternalFrameEvent e)
{
}
public void internalFrameDeiconified(InternalFrameEvent e)
{
}
public void internalFrameActivated(InternalFrameEvent e)
{
}
public void internalFrameDeactivated(InternalFrameEvent e)
{
}
});
Do JPanels have something similar? I've been all over the Net and came out blank...
By the way, I cannot use a JInternalFrame, it has to be a JPanel...
I hope some "wise ones" can help me see the lite...
Thanks
Thor
Last edited by Thor@Flanders (2010-11-22 08:45:50)
Offline
You could use the standard Beans support. A JPanel is a JComponent, and the following method is available:
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
Your "parent" could just add a PropertyChangeListener and listen for PropertyChangeEvents with whatever propertyName you choose to fire
Offline
Hi Skunktrader!
Just tried it...with succes!
Man, I so owe you a beer!
Thanks!
Thor
Offline