下面列出了javax.swing.AbstractButton#isSelected ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
/**
* Gets an undoable edit.
*
* @param type may be ADD_EDIT, REMOVE_EDIT, NAME_EDIT, or EXPRESSION_EDIT
* @param redo the new state
* @param redoRow the newly selected row
* @param redoCol the newly selected column
* @param undo the previous state
* @param undoRow the previously selected row
* @param undoCol the previously selected column
* @param name the name of the edited object
*/
protected UndoableEdit getUndoableEdit(int type, Object redo, int redoRow, int redoCol, Object undo, int undoRow, int undoCol, String name) {
if(type==EXPRESSION_EDIT) {
ArrayList<AbstractButton> selectedButtons = new ArrayList<AbstractButton>();
undo = new Object[] {undo, selectedButtons};
redo = new Object[] {redo, selectedButtons};
if(customButtons!=null) {
for(AbstractButton b : customButtons) {
if(b.isSelected()) {
selectedButtons.add(b);
}
}
}
}
return new DefaultEdit(type, redo, redoRow, redoCol, undo, undoRow, undoCol, name);
}
public void add(AbstractButton b) {
if (b == null) {
return;
}
buttons.addElement(b);
if (b.isSelected()) {
if (modifiedSelection == null) {
modifiedSelection = b.getModel();
} else {
b.setSelected(false);
}
}
b.getModel().setGroup(this);
}
@Override
public void actionPerformed(final ActionEvent e) {
synchronized (panel) {
final AbstractButton button = (AbstractButton) ((OptionElement) panel).findFirstWithName("/" + BTN_NAME).getUIComponent();
final boolean selected = button.isSelected();
panel.setShowMasterSlaveRelationShip(selected);
setupNameAndTooltip(BTN_NAME + "." + (selected ? "on" : "off"));
}
}
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
synchronized (panel) {
final AbstractButton button = (AbstractButton) panel.findFirstWithName("/graph.toggle.layout").getUIComponent();
final boolean selected = button.isSelected();
panel.setAutoLayout(selected);
setupNameAndTooltip("graph.toggle.layout." + (selected ? "on" : "off"));
}
}
protected void disableDecompilationActionPerformed(ActionEvent evt) {
AbstractButton button = (AbstractButton) evt.getSource();
boolean selected = button.isSelected();
Configuration.decompile.set(!selected);
mainFrame.getPanel().disableDecompilationChanged();
}
private static int parseLevel(ButtonGroup buttonGroup) {
Enumeration<AbstractButton> buttonEnumeration = buttonGroup.getElements();
while (buttonEnumeration.hasMoreElements()) {
AbstractButton abstractButton = buttonEnumeration.nextElement();
if (abstractButton.isSelected()) {
String buttonText = abstractButton.getText();
final int index = buttonText.indexOf(" (");
if (index != -1) {
buttonText = buttonText.substring(0, index);
}
return Integer.parseInt(buttonText);
}
}
return-1;
}
private static void removeButtonContentAreaAndBorder(AbstractButton button) {
boolean canRemove = true;
if (button instanceof JToggleButton) {
canRemove = !button.isSelected();
}
if (canRemove) {
button.setContentAreaFilled(false);
button.setBorderPainted(false);
}
}
private String getSelectedButton(ButtonGroup bGroup) {
for (Enumeration<AbstractButton> buttons = bGroup.getElements(); buttons.hasMoreElements();) {
AbstractButton button = buttons.nextElement();
if (button.isSelected()) {
return button.getText();
}
}
return "None";
}
protected void setSubLimiter(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
AbstractButton button = (AbstractButton) evt.getSource();
boolean selected = button.isSelected();
Main.setSubLimiter(selected);
}
protected void autoDeobfuscationActionPerformed(ActionEvent evt) {
AbstractButton button = (AbstractButton) evt.getSource();
boolean selected = button.isSelected();
if (View.showConfirmDialog(mainFrame.getPanel(), translate("message.confirm.autodeobfuscate") + "\r\n" + (selected ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Configuration.autoDeobfuscate.set(selected);
mainFrame.getPanel().autoDeobfuscateChanged();
} else {
button.setSelected(Configuration.autoDeobfuscate.get());
}
}
private void refresh(final AbstractButton b) {
b.setBackground(UISupport.getDefaultBackground());
boolean hovered = Boolean.TRUE.equals(b.getClientProperty(PROP_HOVERED));
boolean filled = b.isEnabled() && (hovered || b.isSelected() || b.isFocusOwner());
b.setOpaque(filled);
b.setContentAreaFilled(filled);
b.repaint();
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
AbstractButton b = (AbstractButton)c;
if (b.isSelected()) {
Color color = c.getBackground();
g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.20f));
g.drawLine(x, y, x + width, y);
g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.10f));
g.drawLine(x, y + 1, x + width, y + 1);
g.drawLine(x, y + 2, x, y + height - 2);
g.setColor(Utilities.deriveColorHSB(color, 0, 0, .24f));
g.drawLine(x, y + height - 1, x + width, y + height-1);
}
}
public String getSelectedRadioButton() {
for (Enumeration<AbstractButton> allButtons = buttonGroup.getElements(); allButtons.hasMoreElements();) {
AbstractButton button = allButtons.nextElement();
if (button.isSelected()) {
return button.getText();
}
}
return null;
}
private void setDefaultState(AbstractButton b) {
if (b.isSelected()) {
setSelectedState(b);
} else {
setNormalState(b);
}
}
protected void simplifyExpressionsActionPerformed(ActionEvent evt) {
AbstractButton button = (AbstractButton) evt.getSource();
boolean selected = button.isSelected();
Configuration.simplifyExpressions.set(selected);
mainFrame.getPanel().autoDeobfuscateChanged();
}
protected void refreshTabStates() {
List<Component> newTabs = new ArrayList<>();
for (int a = 0; a < tabs.getTabCount(); a++) {
JComponent tab = (JComponent) tabs.getTabComponentAt(a);
if (tab == null)
tab = getDefaultTab(a);
TabContainer tabContainer = (TabContainer) tab
.getClientProperty(PROPERTY_TAB_CONTAINER);
if (tabContainer == null) {
tabContainer = new TabContainer(tabs, a, tab);
tab.putClientProperty(PROPERTY_TAB_CONTAINER, tabContainer);
}
newTabs.add(tabContainer);
tab.putClientProperty(PROPERTY_TAB_INDEX, a);
getStyle(tabs).formatControlRowButton(tabs, tabContainer, a);
}
Boolean hideSingleTab = (Boolean) tabs
.getClientProperty(PROPERTY_HIDE_SINGLE_TAB);
if (hideSingleTab == null)
hideSingleTab = Boolean.FALSE;
controlRow.setVisible(!(tabs.getTabCount() <= 1 && hideSingleTab));
if (!(tabsContainer.getLayout() instanceof SplayedLayout)) {
SplayedLayout l = new SplayedLayout(true) {
@Override
protected Collection<JComponent> getEmphasizedComponents(
JComponent container) {
Collection<JComponent> returnValue = super
.getEmphasizedComponents(container);
for (Component c : container.getComponents()) {
if (c instanceof AbstractButton) {
AbstractButton ab = (AbstractButton) c;
if (ab.isSelected())
returnValue.add(ab);
}
}
return returnValue;
}
};
tabsContainer.setLayout(l);
}
int orientation = tabs.getTabPlacement() == SwingConstants.LEFT
|| tabs.getTabPlacement() == SwingConstants.RIGHT ? SwingConstants.VERTICAL
: SwingConstants.HORIZONTAL;
((SplayedLayout) tabsContainer.getLayout()).setOrientation(null,
orientation);
setComponents(tabsContainer, newTabs);
tabsContainer.revalidate();
}
protected void autoOpenLoadedSWFsActionPerformed(ActionEvent evt) {
AbstractButton button = (AbstractButton) evt.getSource();
boolean selected = button.isSelected();
Configuration.autoOpenLoadedSWFs.set(selected);
}
protected void onUploadDirectory()
{
List<StoredObject> sltObj = getSelectedStoredObjects() ;
if (sltObj != null && sltObj.size() > 1)
return ; // should never happen, because in such a case the menu is disable
StoredObject parentObject = (sltObj == null || sltObj.isEmpty()) ? (null) : (sltObj.get(0)) ;
final Container container = getSelectedContainer();
final JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(false);
chooser.setCurrentDirectory(lastFolder);
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY);
final JPanel optionPanel = getOptionPanel ();
chooser.setAccessory(optionPanel);
AbstractButton overwriteCheck = setOverwriteOption (optionPanel) ;
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
{
final File selectedDir = chooser.getSelectedFile();
try
{
boolean overwriteAll = overwriteCheck.isSelected() ;
if (overwriteAll)
{
if (!confirm(getLocalizedString("confirm_overwrite_any_existing_files")))
return ;
}
ops.uploadDirectory(container, parentObject, selectedDir, overwriteAll, getNewSwiftStopRequester (), callback);
// We open the progress window, for it is likely that this operation
// will take a while
//onProgressButton () ;
}
catch (IOException e)
{
logger.error("Error occurred while uploading a directory.", e);
}
lastFolder = chooser.getCurrentDirectory();
}
}
/**
* Ensures that the selected state of the button matches <code>selected</code>.
* <p>
* Note: this works for most toggle button implementations which are derived from
* AbstractButton and relay on {@link AbstractButton#isSelected()} and
* {@link AbstractButton#doClick()} for toggling, such as:
* <ul>
* <li>{@link JCheckBox}</li>
* <li>{@link JRadioButton}</li>
* <li>{@link EmptyBorderToggleButton}</li>
* </ul>
* @param button the button to select
* @param selected true to toggle the button to selected; false for de-selected
*/
public static void setToggleButtonSelected(AbstractButton button, boolean selected) {
boolean isSelected = button.isSelected();
if (isSelected != selected) {
pressButton(button);
}
}