Java Code Examples for javax.swing.JButton#setDisabledIcon()

The following examples show how to use javax.swing.JButton#setDisabledIcon() . 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: ActiveBrowserAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getToolbarPresenter() {
    final JButton button = new JButton();
    button.setAction(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showBrowserPickerPopup( button );
        }
    });
    button.setDisabledIcon(badgeWithArrowIcon(
        ImageUtilities.loadImage(isSmallToolbarIcon() ? DISABLED_SMALL : DISABLED_LARGE)));
    button.setEnabled(false);
    button.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
           if ("PreferredIconSize".equals(evt.getPropertyName())) { // NOI18N
               refreshViewLater(true);
           }
        }
    });
    ProjectBrowserProvider pbp = getBrowserProvider();
    toolbarButton = button;
    updateButton(pbp);
    return button;
}
 
Example 2
Source File: TerminalSupportImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static Component getToolbarPresenter(Action action) {
    JButton button = new JButton(action);
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setText(null);
    button.putClientProperty("hideActionText", Boolean.TRUE); // NOI18N
    Object icon = action.getValue(Action.SMALL_ICON);
    if (icon == null) {
        icon = ImageUtilities.loadImageIcon("org/netbeans/modules/dlight/terminal/action/local_term.png", false);// NOI18N
    }
    if (!(icon instanceof Icon)) {
        throw new IllegalStateException("No icon provided for " + action); // NOI18N
    }
    button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) icon));
    return button;
}
 
Example 3
Source File: ActiveBrowserAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "ActiveBrowserAction.missingProject=Project does not have any browser selected"
})
private void updateButton(ProjectBrowserProvider pbp) {
    JButton tb = toolbarButton;
    if (tb != null) {
        if (lastWebBrowser != null) {
            lastWebBrowser.removeChangeListener(ideBrowserChangeListener);
            lastWebBrowser = null;
        }
        if (pbp == null) {
            tb.setIcon(badgeWithArrowIcon(ImageUtilities.loadImage(isSmallToolbarIcon() ? DISABLED_SMALL : DISABLED_LARGE))); // NOI18N
            tb.setDisabledIcon(badgeWithArrowIcon(ImageUtilities.loadImage(isSmallToolbarIcon() ? DISABLED_SMALL : DISABLED_LARGE))); // NOI18N
            tb.setToolTipText(null);
        } else {
            WebBrowser wb = pbp.getActiveBrowser();
            Image im;
            if (wb != null) {
                im = wb.getIconImage(isSmallToolbarIcon());
                tb.setToolTipText(BrowserUISupport.getLongDisplayName(wb));
                wb.addChangeListener(ideBrowserChangeListener);
            } else {
                im = ImageUtilities.loadImage(isSmallToolbarIcon() ? GENERIC_SMALL : GENERIC_LARGE); // NOI18N
                tb.setToolTipText(Bundle.ActiveBrowserAction_missingProject());
            }
            tb.setIcon(badgeWithArrowIcon(im));
            lastWebBrowser = wb;
        }
        tb.setEnabled(pbp != null);
    }
    JMenu ma = menuAction;
    if (ma != null) {
        ma.setEnabled(pbp != null);
    }
}
 
Example 4
Source File: CompactLabourReport.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
private void addUnitTypes() {
    int row = 1;

    JButton allColonistsButton = createUnitNameButton(Messages.message("report.labour.allColonists"), labourData.getSummary());
    reportPanel.add(allColonistsButton, "cell " + COLONY_COLUMN + " " + row + " 1 " + labourData.getSummary().getUnitSummaryRowCount());

    row = addLocationData(labourData.getSummary().getTotal(), null, row);

    for (UnitType unitType : LabourData.getLabourTypes(getMyPlayer())) {
        LabourData.UnitData unitData = labourData.getUnitData(unitType);

        JButton unitButton = createUnitNameButton(unitData.getUnitName(), unitData);
        int rows = unitData.getUnitSummaryRowCount();
        reportPanel.add(unitButton, "cell " + COLONY_COLUMN + " " + row + " 1 " + rows);

        if (unitData.hasDetails()) {
            row = addLocationData(unitData.getTotal(), null, row);
        } else {
            unitButton.setEnabled(false);
            unitButton.setDisabledIcon(unitButton.getIcon());
            unitButton.setForeground(Color.GRAY);

            reportPanel.add(createEmptyLabel(), "cell " + UNIT_TYPE_COLUMN + " " + row + " " + (COLUMNS - 1) + " 1");
            row++;
        }
    }
}
 
Example 5
Source File: BoardEditor.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets up JButtons
 */
private JButton prepareButton(String iconName, String buttonName, ArrayList<JButton> bList) {
    JButton button = new JButton(buttonName);
    button.addActionListener(this);
    // Get the normal icon
    File file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+".png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$
    Image imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath());
    if (imageButton != null) {
        button.setIcon(new ImageIcon(imageButton));
        // When there is an icon, then the text can be removed
        button.setText("");
    }

    // Get the hover icon
    file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_H.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$
    imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath());
    if (imageButton != null) {
        button.setRolloverIcon(new ImageIcon(imageButton));
    }
    
    // Get the disabled icon, if any
    file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_G.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$
    imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath());
    if (imageButton != null) {
        button.setDisabledIcon(new ImageIcon(imageButton));
    }

    String tt = Messages.getString("BoardEditor."+iconName+"TT");
    if (tt.length() != 0) {
        button.setToolTipText(tt); //$NON-NLS-1$ //$NON-NLS-2$
    }
    button.setMargin(new Insets(0,0,0,0));
    if (bList != null) bList.add(button);
    return button;
}