jtoolbar & OS X 1.4.1

B

B Young

Hi,

I'm having trouble figuring out how to code up my JToolBar to look
good on a Mac and Win32. I use JToolBar.setRollover(true) for the
right effect on Win32 but unfortunately Mac's Java disregards this
apparently, because I get a toolbar with buttons that have beveled
borders at all times.

I want a modern looking toolbar on both platforms using the same code.
I feel that the best way to go "modern" across platforms is with no
border on the buttons by default, and on mouseover, a soft raised
bevel. Am I just going to have to go back to coding this with
mouselisteners like I did before Sun added JToolBar.setRollover(b)?
Uggh. I hate going backwards.

Looking forward to your advice-
Brian
 
R

rbs

Hi,

I'm having trouble figuring out how to code up my JToolBar to look
good on a Mac and Win32. I use JToolBar.setRollover(true) for the
right effect on Win32 but unfortunately Mac's Java disregards this
apparently, because I get a toolbar with buttons that have beveled
borders at all times.

The API for JToolbar.setRollover does say "The implementation
of a look and feel may choose to ignore this property." Myself, I
don't use it anyway as it wasn't added until Java 1.4 and too many
users of my code are on older Windows machines with Java 1.3.1.
I want a modern looking toolbar on both platforms using the same code.
I feel that the best way to go "modern" across platforms is with no
border on the buttons by default, and on mouseover, a soft raised
bevel. Am I just going to have to go back to coding this with
mouselisteners like I did before Sun added JToolBar.setRollover(b)?
Uggh. I hate going backwards.

YMMV, I guess. I've just been checking at various apps on my
Mac (with OS X Panther) and none of the items I use regularly
seem to have any icon rollover effect in their toolbars.
 
S

Steve W. Jackson

rbs said:
:In article <[email protected]>,
: (e-mail address removed) (B Young) wrote:
:
:> Hi,
:>
:> I'm having trouble figuring out how to code up my JToolBar to look
:> good on a Mac and Win32. I use JToolBar.setRollover(true) for the
:> right effect on Win32 but unfortunately Mac's Java disregards this
:> apparently, because I get a toolbar with buttons that have beveled
:> borders at all times.
:
:The API for JToolbar.setRollover does say "The implementation
:eek:f a look and feel may choose to ignore this property." Myself, I
:don't use it anyway as it wasn't added until Java 1.4 and too many
:users of my code are on older Windows machines with Java 1.3.1.
:
:> I want a modern looking toolbar on both platforms using the same code.
:> I feel that the best way to go "modern" across platforms is with no
:> border on the buttons by default, and on mouseover, a soft raised
:> bevel. Am I just going to have to go back to coding this with
:> mouselisteners like I did before Sun added JToolBar.setRollover(b)?
:> Uggh. I hate going backwards.
:
:YMMV, I guess. I've just been checking at various apps on my
:Mac (with OS X Panther) and none of the items I use regularly
:seem to have any icon rollover effect in their toolbars.

But the Java 1.4.1 release from Apple *does not* ignore the rollover
setting. Our app uses it, and I've moved my code to OS X on occasion to
try it out, even though we don't offer it for this platform. I could't
do that for a while, after we upgraded to 1.4 and Apple hadn't got there
yet. So I did it shortly after 1.4.1 was released and saw that
rollovers were working. That's not to say that the "update" following
1.4.1 didn't break this -- I haven't checked again since that time.

= Steve =
 
B

B Young

Hmm, okay. I guess this is about what I expected. Although, I'm
suprised a default JToolBar looks so crappy in OS X since they make
such a big deal about fitting in perfectly to Aqua and everything.

One other issue I just realized- the JToggleButton's I've added to the
toolbar look awful. They appear to be rendered using the Java L&F or
something. They have a dark grey background when pressed?? Bizzare.

Uggh. I'm trying not to get too discouraged at 'porting' this stuff,
because several other apps have done it and look great.

Brian
 
R

rbs

Steve W. Jackson said:
But the Java 1.4.1 release from Apple *does not* ignore the rollover
setting. Our app uses it, and I've moved my code to OS X on occasion to
try it out, even though we don't offer it for this platform. I could't
do that for a while, after we upgraded to 1.4 and Apple hadn't got there
yet. So I did it shortly after 1.4.1 was released and saw that
rollovers were working. That's not to say that the "update" following
1.4.1 didn't break this -- I haven't checked again since that time.

I flipped one of my projects over to compile and run under 1.4.1
today and added setRollover(true) to the JToolBar. I saw no evidence
of a rollover effect. Yes, the buttons changed appearance on a click
but not a mere rollover.

So perhaps there was some visible effect in one of Apple's earlier
1.4.1 releases, but apparently not with the current (build 1.4.1_01-99).
 
R

rbs

Hmm, okay. I guess this is about what I expected. Although, I'm
suprised a default JToolBar looks so crappy in OS X since they make
such a big deal about fitting in perfectly to Aqua and everything.

One other issue I just realized- the JToggleButton's I've added to the
toolbar look awful. They appear to be rendered using the Java L&F or
something. They have a dark grey background when pressed?? Bizzare.

Uggh. I'm trying not to get too discouraged at 'porting' this stuff,
because several other apps have done it and look great.

Hmmmm, I've got JToolBars that look perfectly Mac-like under
OS X. No rollover effect, which I wasn't looking for anyway,
but the look and feel seem pretty much spot on.

On the toolbar itself I call

JToolBar tb = new JToolBar ( );
tb.setBorder (null);
tb.setFloatable (false);

Each of the buttons added to it I create through

private JButton makeToolbarButton (
ImageIcon icon,
String iconText,
Action action,
String tooltip)
{
JButton b = new JButton ( );
b.setAction (action);
b.setIcon (icon);
b.setText (iconText);
b.setHorizontalTextPosition (JButton.CENTER);
b.setVerticalTextPosition (JButton.BOTTOM);

b.setBorder (null);
b.setBorderPainted (false);
b.setContentAreaFilled (false);
b.setMargin (new Insets (0, 0, 0, 0));
b.setRolloverEnabled (true);
b.setToolTipText (tooltip);

return b;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top