add(button);
}
private void addButton(final Action action) {
final JButton button = new PopupButton();
addButtonProperties(button, action);
button.setBorderPainted(false);
button.setAlignmentX(Component.CENTER_ALIGNMENT);
action.putValue(ACTION_VALUE, button);
if(action.equals(((DefaultToolBarModel)mModel).getUpdateAction())) {
mUpdateButton = button;
}
button.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
button.setBorderPainted(true);
}
public void mouseExited(MouseEvent e) {
button.setBorderPainted(false);
}
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger() && !disabled) {
showPopupMenu(e);
}
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger() && !disabled) {
showPopupMenu(e);
}
}
});
action.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("enabled")) {
button.setEnabled(action.isEnabled());
}
}
});
add(button);