commandButton
.addRolloverActionListener(new RolloverActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// System.out.println("Rollover action");
PrimaryRolloverCallback callback = menuEntry
.getRolloverCallback();
if (callback != null) {
callback
.menuEntryActivated(panelLevel2);
} else {
// default callback?
PrimaryRolloverCallback defaultCallback = ribbonAppMenu
.getDefaultCallback();
if (defaultCallback != null) {
defaultCallback
.menuEntryActivated(panelLevel2);
} else {
panelLevel2.removeAll();
panelLevel2.revalidate();
panelLevel2.repaint();
}
}
panelLevel2
.applyComponentOrientation(applicationMenuPopupPanel
.getComponentOrientation());
}
});
} else {
// register a core callback to populate the second level
// panel with secondary menu items
final PrimaryRolloverCallback coreCallback = new PrimaryRolloverCallback() {
@Override
public void menuEntryActivated(JPanel targetPanel) {
targetPanel.removeAll();
targetPanel.setLayout(new BorderLayout());
JRibbonApplicationMenuPopupPanelSecondary secondary = new JRibbonApplicationMenuPopupPanelSecondary(
menuEntry) {
@Override
public void removeNotify() {
super.removeNotify();
commandButton.getPopupModel()
.setPopupShowing(false);
}
};
secondary
.applyComponentOrientation(applicationMenuPopupPanel
.getComponentOrientation());
targetPanel.add(secondary, BorderLayout.CENTER);
}
};
commandButton
.addRolloverActionListener(new RolloverActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
coreCallback
.menuEntryActivated(panelLevel2);
// emulate showing the popup so the
// button remains "selected"
commandButton.getPopupModel()
.setPopupShowing(true);