// System.out.println(prefHeight
// + ":"
// + bandScrollablePanel.getView()
// .getComponentCount());
JPopupPanel popupPanel = new BandHostPopupPanel(
bandScrollablePanel, new Dimension(
ribbon.getWidth(), prefHeight));
int x = ribbon.getLocationOnScreen().x;
int y = ribbon.getLocationOnScreen().y
+ ribbon.getHeight();
// make sure that the popup stays in
// bounds
Rectangle scrBounds = ribbon
.getGraphicsConfiguration().getBounds();
int pw = popupPanel.getPreferredSize().width;
if ((x + pw) > (scrBounds.x + scrBounds.width)) {
x = scrBounds.x + scrBounds.width - pw;
}
int ph = popupPanel.getPreferredSize().height;
if ((y + ph) > (scrBounds.y + scrBounds.height)) {
y = scrBounds.y + scrBounds.height - ph;
}
// get the popup and show it
popupPanel.setPreferredSize(new Dimension(
ribbon.getWidth(), prefHeight));
Popup popup = PopupFactory.getSharedInstance()
.getPopup(taskToggleButton, popupPanel,
x, y);
PopupPanelManager.PopupListener tracker = new PopupPanelManager.PopupListener() {