Get panel size for plugin

I have a plugin which displays content in a JPanel to display my foo filetype. So when you double-click on filetype foo, it displays it in a panel.

Is there a way I can get the size my JPanel will occupy so I can scale to fit?

MArkee

4 comments

Hello mark,

ms> I have a plugin which displays content in a JPanel to display my foo
ms> filetype. So when you double-click on filetype foo, it displays it
ms> in a panel.
ms>
ms> Is there a way I can get the size my JPanel will occupy so I can
ms> scale to fit?

If I understand your question correctly, the regular Swing APIs (JComponent.getBounds()
and the size changed listener) can give you all this information.

Getting the size your panel will occupy before it's created doesn't seem
all that useful to me, because the user can resize the window after it's
created.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

I want the initial size so I can scale to fit the contents. The user can then resize manually.


Markee

0

Hello mark,

ms> I want the initial size so I can scale to fit the contents. The user
ms> can then resize manually.

Perform the scaling on the first size changed event received by your component.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Try AncestorListener or ComponentListener to get notified about becoming
visible.

mark stephens schrieb:

I want the initial size so I can scale to fit the contents. The user can then resize manually.


Markee

0

Please sign in to leave a comment.