Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (c) 2009-2011, EzWare
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.Redistributions
 * in binary form must reproduce the above copyright notice, this list of
 * conditions and the following disclaimer in the documentation and/or
 * other materials provided with the distribution.Neither the name of the
 * EzWare nor the names of its contributors may be used to endorse or
 * promote products derived from this software without specific prior
 * written permission.
package org.oxbow.swingbits.action;
An action representing a drop down menu. Intended to be used for drop down buttons. When assigned to the button shows a pop up menu on click. Also automatically adds "drop down" arrow icon to the right of action's icon.

Eugene Ryzhikov
	private static final long serialVersionUID = 1L;
	private static final Icon DROPDOWN_ICON =  new ImageIconActionDropDownMenu.class.getResource("dropdown.png"));
	private JPopupMenu menu = null;
	private final ActionGroup action;

Action will create a pop up menu out of give ActionGroup

	public ActionDropDownMenuActionGroup actionGroup ) {
		superactionGroup.getName(), createIcon(actionGroup));
		this. = actionGroup;
	private static Icon createIconActionGroup action ) {
		Icon mainIcon = action.getIcon();
		return mainIcon == nullnew CompoundIcon(mainIcon);
	public void actionPerformed(ActionEvent e) {
		if ( !( e.getSource() instanceof Component ) ||
			  == null || .isEmpty() ||
			 !.isEnabled() ) return;
		if (  == null ) {
			 = ActionContainerBuilderFactory.getPopupMenuBuilder().build();
		Component cmpt = (Componente.getSource();
		.showcmpt , 0, cmpt.getHeight() );
New to GrepCode? Check out our FAQ X