Re: Bean only renders itself when inside a JFrame

From: Donald Dietrick <dietrick@bbn.com>
Date: Thu Dec 06 2001 - 21:46:21 EST

Hi Jon,

It depends on the LayoutManager that is assigned to the JPanel. The
MapBean isn't sized or positioned properly when a FlowLayout is used,
for instance, but is OK if the JPanel has a GridLayout. I'm not really
sure where the MapBean is when you add it to a JPanel with a FlowLayout,
but it thinks it's a 10x10 pixel component. That should be visible if
it's in the real estate of the visible area of the JPanel.

Beyond this description of the behavior, I have no explaination for it.

Cheers,

Don

On Thursday, December 6, 2001, at 04:26 PM, Jon K Hellan wrote:

> Hi
>
> I wonder if this is happening to anybody else:
>
> The SimpleMap demo works for me. It is a JFrame containing a MapBean.
> But if I change the hierarchy like this:
>
> JFrame
> JPanel
> MapBean
>
> the map isn't painted.
>
> This is on Linux. Sun j2sdk1.4.0 and jdk1.3.1_01 behave in the same way.
>
> Here's the diff from the 4.4.2 version:
>
> --- orig/com/bbn/openmap/examples/simple/SimpleMap.java
> +++ new/SimpleMap.java
> @@ -23,10 +23,9 @@
> *
> **********************************************************************
> */
>
> -package com.bbn.openmap.examples.simple;
> -
> import java.util.Properties;
> import javax.swing.JFrame;
> +import javax.swing.JPanel;
>
> import com.bbn.openmap.MapBean;
> import com.bbn.openmap.layer.shape.ShapeLayer;
> @@ -74,7 +73,9 @@
> mapBean.add(shapeLayer);
>
> // Add the map to the frame
> - frame.getContentPane().add(mapBean);
> + JPanel jp = new JPanel();
> + jp.add (mapBean);
> + frame.getContentPane().add(jp);
>
> // Display the frame
> frame.setVisible(true);
>
>
> Needless to say, this isn't what I'm really trying to do, just a
> minimal example to isolate the problem.
>
> I thought this could be layout management trouble, but if I wrap
> anything but a map bean in the JPanel, it is rendered properly.
>
> Am I doing something wrong, or is there a bug here?
>
> Jon
>
> --
> Jon Kåre Hellan - Clustra AS - Trondheim, Norway
>
> --
> [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"]
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Donald Dietrick, dietrick@bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[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 Thu Dec 6 21:44:00 2001

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