Project

General

Profile

Actions

Bug #571

closed

fix height of toolbar on windows

Added by Matt Jones about 22 years ago. Updated about 22 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
morpho - general
Target version:
Start date:
08/22/2002
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
571

Description

The toolbar in MorphoFrame is sized by subtracting the height of the menu bar
from the hieight of the Progress Indicator. Unfortunately, JMenuBar.getHeight()
and similar methods always return zero. So I have not yet found a way to
accurately determine the actual menu bar height.

On linux, the menu bar is 24 pixels tall, so I have hardcoded a value for that
OS, although it might not apply to all Look and Feels. It results in a tollbar
that is 1 or 2 pixels too short on Windows, so it looks funny. This needs to be
fixed.

Ideally I would be able to find a reliable way to determine the menu height,
then I could accurately calculate the proper toolbar height.

If that's not possible, I could write a routine that provides fixed defaults for
the various operating system/l&f combinations, and a default. This is a kludge
but would probably work reasonably well.

One other possibility is to try to fix the menu bar at soe height that is
greater than its native height by adding a rigid component (its a box layout) of
a fixed size (e.g., 25 pixels). Again, a kludge, and this one might not work.

Ideas, or suggestions on how to get JMenuBar.getSize() to work?

Actions #1

Updated by Matt Jones about 22 years ago

Looks like brooke fixed it by using getPreferredSize() instead of getSize().
FIXED. (Wow that was easy :)

Actions #2

Updated by Matthew Brooke about 22 years ago

Good grief - I finally manage to fix a bug, and Jones gets here and posts a
comment before me... :-)

Anyway:

Fixed menubar height detection problem by using getPreferredSize(), and fixed
toolbar height hack by using setPreferredSize().

This works because the preferredSize attribute has the correct value even before
the component is displayed, whereas the value returned by calling getSize() is
zero until the component appears on the screen.

In addition to changing code in
src/edu/ucsb/nceas/morpho/framework/MorphoFrame.java, I made 2 methods static in
src/edu/ucs
b/nceas/morpho/framework/UIController.java, and made one of them -
createToolBar() - protected instead of private, so it can be called directly
from MorphoFrame to create a "test" menubar instance in order to get the menu
bar dimensions.

There may be a less wasteful way of doing this, but this was the best I could do
on a Friday afternoon ;-)

Actions #3

Updated by Redmine Admin over 11 years ago

Original Bugzilla ID was 571

Actions

Also available in: Atom PDF