下面列出了javax.swing.JButton#setDisabledIcon ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
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;
}
@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);
}
}
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++;
}
}
}
/**
* 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;
}