javax.swing.ButtonModel Java Examples

The following examples show how to use javax.swing.ButtonModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RPCButton.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
private void initImage() {
	setForeground(LColor.black);
	setBackground(LColor.white);
	setContentAreaFilled(true);
	setFocusPainted(false);
	Border line = BorderFactory.createLineBorder(new LColor(80, 80, 80));
	Border empty = new EmptyBorder(4, 4, 4, 4);
	CompoundBorder border = new CompoundBorder(line, empty);
	setBorder(border);

	getModel().addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			ButtonModel model = (ButtonModel) e.getSource();
			if (model.isRollover()) {
				setBackground(LColor.lightSkyBlue);
			} else if (model.isArmed() || model.isPressed()) {
				setBackground(LColor.lightSkyBlue);
			} else if (model.isSelected()) {
				setBackground(LColor.white);
			} else {
				setBackground(LColor.white);
			}
		}
	});
}
 
Example #2
Source File: XDMButtonUI.java    From xdm with GNU General Public License v2.0 6 votes vote down vote up
public void paint(Graphics g, JComponent c) {
	try {
		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
		
		AbstractButton b = (AbstractButton) c;
		ButtonModel bm = b.getModel();
		if (bm.isRollover()) {
			paintButtonRollOver(g2, b);
		} else {
			paintButtonNormal(g2, b);
		}
		super.paint(g2, c);
	} catch (Exception e) {
	}
}
 
Example #3
Source File: XDMMenuUI.java    From xdm with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
	ButtonModel model = menuItem.getModel();
	Color oldColor = g.getColor();
	if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
		paintButtonPressed(g, menuItem);
	} else {
		g.setColor(this.colorBg);
		// g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
		// g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());//(0,
		// 0, gap + 1, menuItem.getHeight());
		// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
		// if (menuItem.getIcon() != null) {
		// int gap = menuItem.getIcon().getIconWidth() + 2;
		// g.setColor(this.darkColor);
		// g.drawLine(gap, 0, gap, menuItem.getHeight());
		// g.setColor(this.lightColor);
		// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
		// }
	}
	g.setColor(oldColor);
}
 
Example #4
Source File: FlatButtonUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
protected Color getBackground( JComponent c ) {
	if( !c.isEnabled() )
		return disabledBackground;

	// toolbar button
	if( isToolBarButton( c ) ) {
		ButtonModel model = ((AbstractButton)c).getModel();
		if( model.isPressed() )
			return toolbarPressedBackground;
		if( model.isRollover() )
			return toolbarHoverBackground;

		// use background of toolbar
		return c.getParent().getBackground();
	}

	boolean def = isDefaultButton( c );
	return buttonStateColor( c,
		getBackgroundBase( c, def ),
		null,
		isCustomBackground( c.getBackground() ) ? null : (def ? defaultFocusedBackground : focusedBackground),
		def ? defaultHoverBackground : hoverBackground,
		def ? defaultPressedBackground : pressedBackground );
}
 
Example #5
Source File: FlatToggleButtonUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
@Override
protected Color getBackground( JComponent c ) {
	ButtonModel model = ((AbstractButton)c).getModel();

	if( model.isSelected() ) {
		// in toolbar use same colors for disabled and enabled because
		// we assume that toolbar icon is shown disabled
		boolean toolBarButton = isToolBarButton( c );
		return buttonStateColor( c,
			toolBarButton ? toolbarSelectedBackground : selectedBackground,
			toolBarButton ? toolbarSelectedBackground : disabledSelectedBackground,
			null, null,
			toolBarButton ? toolbarPressedBackground : pressedBackground );
	}

	return super.getBackground( c );
}
 
Example #6
Source File: BECheckBoxMenuItemUI.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y) 
    	{
    		AbstractButton b = (AbstractButton) c;
    		ButtonModel model = b.getModel();
    		
    		Image selectedImg = __IconFactory__.getInstance().getCheckboxMenuItemSelectedNormalIcon().getImage();
    		boolean isSelected = model.isSelected();
//    		boolean isArmed = model.isArmed();
    		if (isSelected) 
    		{
//    			if(isArmed)
//    				selectedImg = __IconFactory__.getInstance().getCheckboxMenuItemSelectedRoverIcon().getImage();
    		}
    		else
    			selectedImg = __IconFactory__.getInstance().getCheckboxMenuItemNoneIcon().getImage();

    		g.drawImage(selectedImg
    				, x+(usedForVista?5:-4)//* 注意:当用于windows平台专用主类且处于Vista及更高版win时要做不一样的处理哦
    				, y - 3
    				, null);
    	}
 
Example #7
Source File: EditMediator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void register(Project project,
                            AntProjectHelper helper,
                            ReferenceHelper refHelper,
                            ListComponent list,
                            ButtonModel addJar,
                            ButtonModel addLibrary, 
                            ButtonModel addAntArtifact,
                            ButtonModel remove, 
                            ButtonModel moveUp,
                            ButtonModel moveDown, 
                            ButtonModel edit,
                            Document libPath,
                            ClassPathUiSupport.Callback callback) {    
    register(project, helper, refHelper, list, addJar, addLibrary, 
            addAntArtifact, remove, moveUp, moveDown, edit, false, libPath,
            callback);
}
 
Example #8
Source File: FileChooserEditor.java    From niftyeditor with Apache License 2.0 6 votes vote down vote up
public String traslateFile() {
    File selected = jFileChooser1.getSelectedFile();
    ButtonModel selection = group.getSelection(); 
    if(selection.equals(absolute.getModel())){
       editedValue= selected.getAbsolutePath();
    }else if (selection.equals(copy.getModel())){
        
        try { 
            File dest = new File(this.copyText.getText()+"//"+selected.getName());
            FileUtils.copyFile(selected, dest);
            editedValue = assets.toURI().relativize(dest.toURI()).getPath();
        } catch (IOException ex) {
            Logger.getLogger(FileChooserEditor.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }else{
          editedValue= createReletive(selected);
    }
    return editedValue;
}
 
Example #9
Source File: SeaGlassButtonUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the Icon to use in painting the button.
 *
 * @param  b the button.
 *
 * @return the icon.
 */
protected Icon getIcon(AbstractButton b) {
    Icon        icon  = b.getIcon();
    ButtonModel model = b.getModel();

    if (!model.isEnabled()) {
        icon = getSynthDisabledIcon(b, icon);
    } else if (model.isPressed() && model.isArmed()) {
        icon = getPressedIcon(b, getSelectedIcon(b, icon));
    } else if (b.isRolloverEnabled() && model.isRollover()) {
        icon = getRolloverIcon(b, getSelectedIcon(b, icon));
    } else if (model.isSelected()) {
        icon = getSelectedIcon(b, icon);
    } else {
        icon = getEnabledIcon(b, icon);
    }

    if (icon == null) {
        return getDefaultIcon(b);
    }

    return icon;
}
 
Example #10
Source File: MnemonicsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSetLocalizedTextWithModel() throws Exception {
    ButtonModel m = new DefaultButtonModel();
    JButton b = new JButton();
    Mnemonics.setLocalizedText(b, "Hello &There");
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
    b.setModel(m);
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
}
 
Example #11
Source File: ProfilerPopup.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
Example #12
Source File: SeaGlassGraphicsUtils.java    From seaglass with Apache License 2.0 6 votes vote down vote up
static void paintIcon(Graphics g, SeaGlassMenuItemLayoutHelper lh,
                      MenuItemLayoutHelper.LayoutResult lr) {
    if (lh.getIcon() != null) {
        Icon icon;
        JMenuItem mi = lh.getMenuItem();
        ButtonModel model = mi.getModel();
        if (!model.isEnabled()) {
            icon = mi.getDisabledIcon();
        } else if (model.isPressed() && model.isArmed()) {
            icon = mi.getPressedIcon();
            if (icon == null) {
                // Use default icon
                icon = mi.getIcon();
            }
        } else {
            icon = mi.getIcon();
        }

        if (icon != null) {
            Rectangle iconRect = lr.getIconRect();
            SynthIcon.paintIcon(icon, lh.getContext(), g, iconRect.x,
                    iconRect.y, iconRect.width, iconRect.height);
        }
    }
}
 
Example #13
Source File: PathUiSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void register(PhpProject project, JList<BasePathSupport.Item> list, ButtonModel addFolder,
        ButtonModel remove, ButtonModel moveUp, ButtonModel moveDown,
        FileChooserDirectoryHandler directoryHandler) {

    EditMediator em = new EditMediator(project, list, addFolder, remove, moveUp, moveDown, directoryHandler);

    // Register the listener on all buttons
    addFolder.addActionListener(em);
    remove.addActionListener(em);
    moveUp.addActionListener(em);
    moveDown.addActionListener(em);
    // On list selection
    em.selectionModel.addListSelectionListener(em);
    // Set the initial state of the buttons
    em.valueChanged(null);
}
 
Example #14
Source File: PathUiSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void register(JList<BasePathSupport.Item> list, ButtonModel addFolder,
        ButtonModel remove, ButtonModel moveUp, ButtonModel moveDown,
        FileChooserDirectoryHandler directoryHandler) {

    EditMediator em = new EditMediator(list, addFolder, remove, moveUp, moveDown, directoryHandler);

    // Register the listener on all buttons
    addFolder.addActionListener(em);
    remove.addActionListener(em);
    moveUp.addActionListener(em);
    moveDown.addActionListener(em);
    // On list selection
    em.selectionModel.addListSelectionListener(em);
    // Set the initial state of the buttons
    em.valueChanged(null);
}
 
Example #15
Source File: LuckButtonUI.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public void paint(Graphics g, JComponent c)
{
    AbstractButton b = (AbstractButton) c;

    ButtonModel model = b.getModel();

    paintBg(g, (AbstractButton) c);

    // 设置组件偏移,以达到视觉上的按下和弹起效果
    // Set the component offsets to achieve visual depress and bounce
    if(model.isPressed() && model.isArmed() && b.getIcon() == null)
    {
        g.translate(2, 1);
    }

    super.paint(g, c);

    if(model.isPressed() && model.isArmed() && b.getIcon() == null)
    {
        g.translate(-2, -1);
    }
}
 
Example #16
Source File: ProfilerPopup.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
Example #17
Source File: ToggleButtonGroup.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setSelected(ButtonModel m, boolean b) {
    if (!b && m == modifiedSelection) {
        modifiedSelection = null;
        return;
    }
    if (b && m != null && m != modifiedSelection) {
        ButtonModel oldSelection = modifiedSelection;
        modifiedSelection = m;
        if (oldSelection != null) {
            oldSelection.setSelected(false);
        }
        m.setSelected(true);
    }
}
 
Example #18
Source File: IconPackagerButtonBarUI.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public void paint(Graphics g, JComponent c) {
  AbstractButton button = (AbstractButton)c;

  if (button.getModel().isSelected()) {
    Color oldColor = g.getColor();
    g.setColor(selectedBackground);
    g.fillRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1, 5, 5);

    g.setColor(selectedBorder);
    g.drawRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1, 5, 5);

    g.setColor(oldColor);
  }

  // this is a tweak to get the View with the color we expect it to be. We
  // change directly the color of the button
  if (c.getClientProperty(BasicHTML.propertyKey) != null) {
    ButtonModel model = button.getModel();
    if (model.isEnabled()) {
      if (model.isSelected()) {
        button.setForeground(selectedForeground);
      } else {
        button.setForeground(unselectedForeground);
      }
    } else {
      button.setForeground(unselectedForeground.darker());
    }
  }

  super.paint(g, c);
}
 
Example #19
Source File: ButtonBorder.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public void paintBorder(Component c, Graphics g, int x, int y, int width,
  int height) {
  if (c instanceof AbstractButton) {
    AbstractButton b = (AbstractButton)c;
    ButtonModel model = b.getModel();

    boolean isPressed;
    boolean isRollover;
    boolean isEnabled;

    isPressed = model.isPressed() && model.isArmed();
    isRollover = b.isRolloverEnabled() && model.isRollover();
    isEnabled = b.isEnabled();

    if (!isEnabled) {
      paintDisabled(b, g, x, y, width, height);
    } else {
      if (isPressed) {
        paintPressed(b, g, x, y, width, height);
      } else if (isRollover) {
        paintRollover(b, g, x, y, width, height);
      } else {
        paintNormal(b, g, x, y, width, height);
      }
    }
  }
}
 
Example #20
Source File: NavlinkUI.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
public void paint(Graphics g, JComponent c) {
	AbstractButton b = (AbstractButton) c;
	ButtonModel model = b.getModel();

	String text = layout(b, g.getFontMetrics(), b.getWidth(), b.getHeight());

	clearTextShiftOffset();

	if (model.isArmed() && model.isPressed()) {
		paintButtonPressed(g, b);
	} else if (b.isRolloverEnabled() && model.isRollover()) {
		paintButtonPressed(g, b);
	}

	if (b.getIcon() != null) {
		paintIcon(g, c, iconRect);
	}

	if (b.isFocusPainted() && b.isFocusOwner()) {
		paintFocus(g, b, viewRect, textRect, iconRect);
		if (iconRect != null && iconRect.width > 0 && iconRect.height > 0) {
			if (b.getIcon() != null) {
				paintIcon(g, c, iconRect);
			}
		}
	}

	if (text != null && !text.equals("")) {
		Graphics2D g2 = (Graphics2D) g.create();
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

		View v = (View) c.getClientProperty(BasicHTML.propertyKey);
		if (v != null) {
			v.paint(g2, textRect);
		} else {
			paintText(g2, b, textRect, text);
		}
	}
}
 
Example #21
Source File: ContentProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public ListCellRenderer getListCellRenderer(
        @NonNull final JList list,
        @NonNull final ButtonModel caseSensitive) {
    Parameters.notNull("list", list);   //NOI18N
    Parameters.notNull("caseSensitive", caseSensitive); //NOI18N
    return ItemRenderer.Builder.create(
        list,
        caseSensitive,
        new SymbolDescriptorCovertor()).build();
}
 
Example #22
Source File: ButtonState.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Create a ButtonState that captures a ButtonModel's current state.
 */
public Boolean(ButtonModel model) {
	isArmed = model.isArmed();
	isEnabled = model.isEnabled();
	isPressed = model.isPressed();
	isRollover = model.isRollover();
	isSelected = model.isSelected();
}
 
Example #23
Source File: ToggleHighlightSearchAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setModel(ButtonModel model) {
    ButtonModel oldModel = getModel();
    if (oldModel != null) {
        oldModel.removeChangeListener(this);
    }
    super.setModel(model);
    ButtonModel newModel = getModel();
    if (newModel != null) {
        newModel.addChangeListener(this);
    }
    stateChanged(null);
}
 
Example #24
Source File: MenuItemManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
	if (action != null) {
		action.removePropertyChangeListener(this);
	}

	if (menuItem != null) {
		ButtonModel buttonModel = menuItem.getModel();
		buttonModel.removeChangeListener(buttonModelChangeListener);
		menuItem = null;
	}

	action = null;
}
 
Example #25
Source File: MenuUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
	JMenu menu = (JMenu) menuItem;
	ButtonModel buttonmodel = menu.getModel();
	int w = menu.getWidth();
	int h = menu.getHeight();
	Color oldColor = g.getColor();
	if (!menu.isContentAreaFilled() || !menu.isOpaque()) {
		// do nothing
	} else {
		if (menu.isTopLevelMenu()) {
			if (buttonmodel.isSelected()) {
				CachedPainter.drawMenuBackground(menuItem, g, 0, 0, w, h);
			} else if (buttonmodel.isRollover() && buttonmodel.isEnabled()) {
				g.setColor(Colors.MENUBAR_BACKGROUND_HIGHLIGHT);
				g.fillRect(0, 0, w, h);
			} else {
				if (menuItem.getParent() instanceof JMenuBar) {
					((MenuBarUI) ((JMenuBar) menuItem.getParent()).getUI()).update(g, menuItem);
				}
			}
		} else {
			if (!menuItem.getModel().isSelected()) {
				RapidLookTools.drawMenuItemFading(menuItem, g);
			} else {
				RapidLookTools.drawMenuItemBackground(g, menuItem);
			}
		}
	}
	g.setColor(oldColor);
}
 
Example #26
Source File: FlatMenuUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintBackground( Graphics g, Color selectionBackground ) {
	ButtonModel model = menuItem.getModel();
	if( model.isRollover() && !model.isArmed() && !model.isSelected() &&
		model.isEnabled() && ((JMenu)menuItem).isTopLevelMenu() )
	{
		g.setColor( deriveBackground( hoverBackground ) );
		g.fillRect( 0, 0, menuItem.getWidth(), menuItem.getHeight() );
	} else
		super.paintBackground( g, selectionBackground );
}
 
Example #27
Source File: BERadioButtonMenuItemUI.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
     * Draws the background of the menu item.
     * 
     * @param g the paint graphics
     * @param menuItem menu item to be painted
     * @param bgColor selection background color
     * @since 1.4
     */
    protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) 
    {
    	ButtonModel model = menuItem.getModel();
    	Color oldColor = g.getColor();
    	int menuWidth = menuItem.getWidth();
    	int menuHeight = menuItem.getHeight();

    	if(menuItem.isOpaque()) 
    	{
    		if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) 
    		{
    			g.setColor(bgColor);
    			g.fillRect(0,0, menuWidth, menuHeight);
    		} 
    		else 
    		{
    			g.setColor(menuItem.getBackground());
    			g.fillRect(0,0, menuWidth, menuHeight);
    		}
    		g.setColor(oldColor);
    	}
    	else if (model.isArmed() || (menuItem instanceof JMenu &&
    			model.isSelected())) 
    	{
//    		g.setColor(bgColor);
//    		g.fillRect(0,0, menuWidth, menuHeight);
//    		g.setColor(oldColor);
    		
    		//由jb2011改用NinePatch图来填充
			__Icon9Factory__.getInstance().getBgIcon_ItemSelected()
				.draw((Graphics2D)g, 0, 0, menuWidth, menuHeight);
    	}
    }
 
Example #28
Source File: StyledButtonUI.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void paint(Graphics graphics, JComponent button) {
	paintBackground(graphics, button);

	// Restore normal look after pressing ends, if needed
	if (button instanceof AbstractButton) {
		ButtonModel model = ((AbstractButton) button).getModel();
		if (!model.isPressed()) {
			// Try to avoid switching borders if the button has none or custom
			// borders
			if (button.getBorder().equals(style.getBorderDown())) {
				button.setBorder(style.getBorder());
			}
		}
		if (model.isRollover()) {
			hilite(graphics, button);
		}

		if (button instanceof JButton) {
			if (((JButton) button).isDefaultButton()) {
				Insets insets = button.getInsets();
				graphics.setColor(style.getShadowColor());
				int width = button.getWidth() - insets.right - insets.left - 3;
				int height = button.getHeight() - insets.top - insets.bottom - 3;
				graphics.drawRect(insets.left + 1, insets.right + 1, width, height);
			}
		}
	}

	super.paint(graphics, button);
}
 
Example #29
Source File: LuckCheckboxIcon.java    From littleluck with Apache License 2.0 5 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y)
{
    AbstractButton btn = (AbstractButton) c;

    ButtonModel model = btn.getModel();

    Image image = getPreImg(c, model);

    if (image != null)
    {
        g.drawImage(image, x, y, getIconWidth(), getIconHeight(), null);
    }
}
 
Example #30
Source File: TransferMaskDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static Product[] getSelectedProducts(Map<Product, ButtonModel> buttonMap) {
    List<Product> selectedProducts = new ArrayList<Product>(buttonMap.size());
    for (Map.Entry<Product, ButtonModel> entry : buttonMap.entrySet()) {
        Product product = entry.getKey();
        ButtonModel buttonModel = entry.getValue();
        if (buttonModel.isSelected()) {
            selectedProducts.add(product);
        }
    }
    return selectedProducts.toArray(new Product[selectedProducts.size()]);
}