[Jscroll-developer] Patch: setTitle() for JScrollInternalFrame
Brought to you by:
tom_tessier
|
From: Ted C. <ted...@ya...> - 2004-03-23 12:27:56
|
Below are snippets of some code changes I made to JScroll. I like it
very much, but was annoyed that calls to setTitle() on my
JInternalFrames didn't show in JScroll. Below are the few new lines; it
works for me. Btw: I know that keeping the origin is not necessary, the
listener could be directly attached, but maybe we find something useful
later.
Best,
Ted
The first set of changes go to JScrollInternalFrame:
- add "private JInternalFrame origin;" to the declaration block. This
variable keeps reference to the original JInternalFrame.
- add a method setTitle():
/**
* Set the title of this JInternalFrame and the Button
*/
public void setTitle(String title) {
super.setTitle(title);
if (associatedMenuButton != null)
associatedMenuButton.setText(title);
if (associatedButton != null)
associatedButton.setText(title);
}
- add a method setJInternalFrame()
/**
* save the original JInternalFrame and attache a
* PropertyChangeListener to capture Title changes
* of the origin.
*
* @param origin the JInternalFrame the application works with
*/
public void setJInternalFrame(JInternalFrame origin) {
this.origin = origin;
this.origin.addPropertyChangeListener(new
PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent pce) {
if(pce.getPropertyName()==JInternalFrame.TITLE_PROPERTY)
{
setTitle((String)pce.getNewValue());
}
}
});
}
Finally, in JScrollDesktopPane, add the following line to
getWrappedFrame(JInternalFrame f):
b.setJInternalFrame(f);
--
Freedom is an income that can't be taxed
|