Re: [OpenMap Users] add JButton in a layer

From: Don Dietrick <dietrick_at_bbn.com>
Date: Wed, 24 Sep 2008 14:20:17 -0400

The thing that makes this not-so-obvious is that OpenMap layers
override the paint() method so that the
com.bbn.openmap.layer.policy.RenderPolicy object handles the rendering
of the OMGraphicList, instead of using the paint(...) method hierarchy
of the Swing ancestry.

The easiest thing to do is extend a RenderPolicy class and set that on
your layer. You'll probably want the RenderPolicy object to call
paintAll(java.awt.Graphics) on the layer. In addition to painting the
OMGraphicList.

RenderPolicy object can be set in the layer's constructor, or you can
set it in the properties, too.

Hope this helps,

Don

On Sep 24, 2008, at 1:03 PM, Christopher Franklin wrote:

> Ruben,
>
> Someone can correct me if I am wrong but I don't think it is
> possible to embed Swing objects inside the Openmap bean. I do know
> for a fact that you can embed the openmap bean into a Swing
> container along with your button and link the functionality but it
> sounds like you really want the button as part of the map itself. If
> this is the case the only way I can think of to do this is to create
> an image to represent your button and to place this image into a
> layer as an OMGraphic. You can then hook in a mouse listener to the
> OMGraphic and interpret the clicks as you see fit. I hope one of
> these two solutions will work for you!
>
> Chris
>
> Ruben DF wrote:
>>
>> Hi,
>>
>> How can I add a Jbutton in the layer? I tried with this
>> unsuccessfully (JButton does not appear in the layer)
>>
>> JButton jb = new JButton("hello");
>> jb.setLocation(100,100);
>> myLayer.add(jb);
>>
>> I also tried passing the Jbutton in OMGraphicList.add(JButton) but
>> it is not correct because add is expecting a OMGraphic...
>>
>> Is there any way to convert JButton to OMGraphic?
>>
>> Thanks in advance
>> Best regards
>>
>>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Wed Sep 24 2008 - 14:21:27 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT