[izpack-devel] Suggestion for Modification On Another Class
Hal Vaughan
hal at thresholddigital.com
Sun Jan 15 05:20:11 CET 2006
Hi, Fabrice!
How's the weekend going? I hope you're having fun and doing lots of the
things I'm dreaming of doing once I get all this stuff done! (What's the
weather like there now? We're having almost a heat wave and temperatures are
more like we expect in April than January, but a weather front moved through
last night, bringing thunder storms and it's suddenly getting cold!)
I'm working on a Path panel. I wanted to use Klaus' PathInputPanel, but there
are enough parts of it custom tailored to TargetPanel that it won't work, at
least not easily. I tried using Klaus' other panel, PathSelectionPanel, but
I find one small problem, here it is:
There are two components in PathSelectionPanel, a JTextField and a JButton.
You can access the JTextField, which lets you get or set the text and add a
listener, but there is no way to access the JButton, which brings up a
JFileChooser. I'm suggesting making a small modification to this class so
the button can be accessed. In my case, I'd like to add an ActionListener
that is slightly different than the one Klaus uses. Here's an example of
what I *think* is a problem with the current ActionListener: If you the
current path in the JTextField is /usr/lib/openoffice, which is the directory
you plan on installing to, and the JFileChooser realizes the entire path does
not exist, it defaults to /home/username. Without going into details, I want
a different behavior.
I am suggestion to add one method at the end of PathSelectionPanel:
public JButton getBrowseButton()
{
return browseButton;
}
That's it! Just allow another class using PathSelectionPanel to access the
browseButton to change the text or change the ActionListener. The only
downside I can see is that this allows people to change the behavior of the
browseButton so it won't always be the same.
At this point, I'm creating a class, AlteredPathSelectionPanel, so I can use
it with this change. If it's acceptable to add this one method to
PathSelectionPanel, I can change my code to use the regular class. As I've
said, I am trying to make sure that I do not change existing code or add
things like this to existing classes, but this seems to make sense, so I
thought I'd bring it up and see what you thought.
Keep well,
Hal
More information about the izpack-devel
mailing list