Vova Reznik skrev:
>> Vova Reznik:
>>
[quoted text clipped - 9 lines]
>
> Size of JPopuMenu depends on preferred size of inside component.
It still does not look like a real toolbar drop-down, I am missing the
little "expand" icon. Also, this arrow toolbar button is typically
pressed down while the menu is shown. I just though there would be a
standard way for this.
Thanks though,
Casper
Vova Reznik - 24 Sep 2005 14:55 GMT
> It still does not look like a real toolbar drop-down, I am missing the
> little "expand" icon. Also, this arrow toolbar button is typically
Little "expand" icon is a button.
> pressed down while the menu is shown. I just though there would be a
> standard way for this.
Everything is possible and not everywhere are standard ways.
Casper - 24 Sep 2005 17:17 GMT
Vova Reznik skrev:
>> It still does not look like a real toolbar drop-down, I am missing the
>> little "expand" icon. Also, this arrow toolbar button is typically
[quoted text clipped - 5 lines]
>
> Everything is possible and not everywhere are standard ways.
No but had there been a standard way, it would be pretty dumb to put
together a hack. Hence the question to this newsgroup.
Casper
Kari Ikonen - 25 Sep 2005 20:46 GMT
> It still does not look like a real toolbar drop-down, I am missing the
> little "expand" icon. Also, this arrow toolbar button is typically
> pressed down while the menu is shown. I just though there would be a
> standard way for this.
Just define appropriate "arrow-down" icon and attach it into Action
-button whichyou place into toolbar. That works easily if you want to have
"[foobar-text v]" -style toolbar menubutton. However, I'm guessing you are
wanting to have "[[some-icon]v]".
Such can be done approximately like this:
Ingredients are:
1) One standard toolbar A ImageIcon (assuming 24x24)
2) One dropdown arrow B ImageIcon (8x24)
3)
public Icon merge(Icon pA, Icon pB) {
final Image a = ((ImageIcon)pA).getImage();
final Image b = ((ImageIcon)pB).getImage();
final int w1 = pA.getIconWidth();
final int w2 = pB.getIconWidth();
final int h = pA.getIconHeight() + pB.getIconHeight();
final BufferedImage image = new BufferedImage(w1+w2, h);
Graphics2D g2d = image.createGraphics();
g2d.drawImage(0, 0, a);
g2d.drawImage(w1, 0, b);
return new ImageIcon(image);
}
To be honest, you actually need to also have special ToolBarMenuButton, to
manage menu show/hide logic properly. I.e. some additional logic is needed
to make it behave correctly (= in similar manner than menubar menus).
For example,
- Managing keyboard
- Cancelling menu (escape, mouseclick)
- Opening another menu while toolbar menubutton's menu is still open

Signature
KI
Casper - 26 Sep 2005 12:18 GMT
Kari Ikonen:
> Ingredients are:
> 1) One standard toolbar A ImageIcon (assuming 24x24)
[quoted text clipped - 12 lines]
> return new ImageIcon(image);
> }
Thanks for the idea. However doing this still does not mimic other
implementations very well, particulary the dual border in respect to
rollover/pressdown events.
I am implementing my solution as a JMenuComboButton which subclasses
JToolBar and has a button for the action itself and one for the
drop-down triggering. I then subclass these JButton's and add my own logic.
Casper