Re: Newbie help: Setting width/height on the fly

From: Joshua Trutwin <Joshua.Trutwin@udlp.com>
Date: Tue Oct 08 2002 - 15:12:05 EDT

Thanks, that did it!

Josh

>>> Don Dietrick <dietrick@bbn.com> 10/08/02 01:17PM >>>
Hi Joshua,

I think if you set a LayoutManager in the JPanel and then add the
MapBean to that, it should work as expected. I usually use a
BorderLayout and add the MapBean to the center section. See the
com.bbn.openmap.gui.OpenMapFrame as an example.

- Don

On Tuesday, October 8, 2002, at 01:46 PM, Joshua Trutwin wrote:

> I am new to the OpenMap API, and somewhat new to Swing so please
bear
> with me!
>
> I want to integrate OpenMap into an existing application where we
model
> a crew interface to an Army vehicle. Depending on the screen the
crew
> member is looking at, they may have a different sized view of the
map
> (e.g. full screen, 1/4 screen, etc.).
>
> Our architecture currently requires our GUI components to extend
> JComponent or JPanel, basically a viewport that shows only the map
and
> none of the controls for zoom, pan, etc.
>
> I am to the point where I can load the map in a JPanel and I can
change
> the height and width of the JPanel, but the openmap bean does not
> respond to these changes.
>
> I am curious what would be the best solution to this problem. I
tried
> to play with projections, but I cannot seem to set any of the
> properties
> for width/height on a projection object. I looked over the examples
in
> com/bbn/openmap/examples/simple and it seems like it should just work

> on
> it's own. (Except those examples use a JFrame instead of a JPanel).
>
> Here is some sample code:
>
> public class NGMapViewport extends JPanel {
> private int width = 400;
> private int height = 600;
>
> public NGMapViewport () {
> MapHandler mapHandler = new MapHandler();
> bufferedMapBean = new BufferedMapBean();
>
> // set center, scale, layers, etc.
>
> super.add(bufferedMapBean);
> setWidth(width);
> setHeight(height);
> setVisible(true);
> }
>
> public void setHeight (int height) {
> this.height = height;
> setPreferredSize(new Dimension(width, height));
> setMaximumSize(new Dimension(width, height));
> setMinimumSize(new Dimension(width, height));
> setSize(new Dimension(width, height));
> revalidate();
> repaint();
> }
>
> // setWidth pretty much the same
> }
>
> Thanks in advance.
>
> Josh
>
>
>
> --
> [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"]
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 Tue Oct 8 15:14:07 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT