Hi Michael,
You need an ActionListener somewhere to catch the event generated by
your palette widgets. So, your layer can act as the ActionListener for
all of your events, in which case you would attach an ActionCommand (a
unique String) to the widget, so your ActionListener can figure out
what happened - you would retrieve the command from the ActionEvent in
the actionPerformed method, and then react accordingly.
You might have to define commands for the other layer functions that
your ActionListener is already doing, so there is no conflict with the
new functions.
The other thing you can do is to define another ActionListener inline
to your widget, like:
JButton button = new JButton("Quit Program");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
// do whatever you want when the button gets pressed
System.exit(0);
}
});
That may get tiresome if you have a lot of widgets, though.
- Don
On Wednesday, August 21, 2002, at 11:22 AM, Mulvaney, Michael wrote:
> Don,
> That's a good start and it's given me a good base to work from. I
> have one minor question. Again, in the RPF layer as my guide, I
> noticed you use an ActionListener to effect changes made in the RPF
> coverage tool pallette. The problem is in my current layer that I'm
> trying to add this to, there already is an ActionListener for edit
> functions that one performs on the layer. Is an ActionListener
> absolutely necessary to effect a change to the showing of lines, like
> I'm going for. If I add an new ActionListener or add to the current
> ActionListener, would I adversely affect the edit functions I already
> have in the layer?
>
> -Mike
>
> -----Original Message-----
> From: Don Dietrick [mailto:dietrick@bbn.com]
> Sent: Wednesday, August 21, 2002 10:46 AM
> To: Mulvaney, Michael
> Cc: 'openmap-users@bbn.com'
> Subject: Re: Creating a pallette for a created layer
>
>
> Michael,
>
> Your layer just has to override the getGUI() method and return the
> java.awt.Component you want to be on the palette. The Layer class
> returns null by default, so if you don't override this method, you get
> the 'No Palette' palette. I usually keep all the code for the palette
> within the layer, since the palette usually controls the layer
> parameters. Layers that have other components that manage their data,
> like the LocationLayer, can call some method on those components (I
> usually call that method getGUI, too) to get their java.awt.Components
> to use on the palette. Whatever works for you, since it's pretty
> isolated to whatever your layer is doing in the first place.
>
> Hope this helps,
>
> Don
>
>
> On Wednesday, August 21, 2002, at 09:46 AM, Mulvaney, Michael wrote:
>
> > Hello fellow open-mappers,
> > I have a created layer that currently displays up to 7 different
> > "line-types" each distinguished by one of seven different colors. On
> > the layer tool, when I click the pallette button for this layer,
> > obviously I get a "No Pallette" display. I would like to know if
> > anyone knows how to create a pallette for this layer with the
> > following parameters:
> >
> > 1)Kinda like how the rpf coverage tool allows you to turn off
> > different map sets, the pallette tool I want to create would allow
> you
> > to turn on and off the individual line-types. The reason for asking
> > this, is that this would probably be more user-friendly than making
> > each individual lines a separate layer. For a bit of clarification,
> > this is a layer where I have for example 20 lines of color 1, 50
> lines
> > of color 2, etc, and I'd like to be able to not show color 1, but do
> > show color 2, or have both on or neither on.
> >
> > 2)If possible, I'd like to also give to user the ability to change
> the
> > color of the lines and save the user's preference dynamically. This
> > is not too high a priority as the other ability is more important to
> > the user.
> >
> > If anyone has some basic skeletons that I can use to create such a
> > pallette, you help would be greatly appreciated. I'm a bit of a
> > novice at this open map stuff, so my only other question would be
> > where to place this code for the pallette? Should I put it in the
> > same class as the rest of the infomation for the layer? Or should it
> > become a separate class called by the layer's class. Again any
> > feedback and information would be greatly appreciated.
> >
> > -Mike
> >
> >
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Don Dietrick, BBN Technologies, dietrick@bbn.com
> 10 Moulton Street, Cambridge, MA 02138
> 617-873-3031 [fax]-2794
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, BBN Technologies, dietrick@bbn.com
10 Moulton Street, Cambridge, MA 02138
617-873-3031 [fax]-2794
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Wed Aug 21 12:15:57 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT