當前位置: 首頁>>代碼示例>>Java>>正文


Java JToggleButton.setSelected方法代碼示例

本文整理匯總了Java中javax.swing.JToggleButton.setSelected方法的典型用法代碼示例。如果您正苦於以下問題:Java JToggleButton.setSelected方法的具體用法?Java JToggleButton.setSelected怎麽用?Java JToggleButton.setSelected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JToggleButton的用法示例。


在下文中一共展示了JToggleButton.setSelected方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newOptionButton

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton newOptionButton(Icon icon, String tooltip, String accessibleName, final String property) {
JToggleButton newButton = new JToggleButton(icon);
newButton.setToolTipText(tooltip);
newButton.getAccessibleContext().setAccessibleName(accessibleName);
boolean isSelected = NbPreferences.forModule(StatisticsPanel.class).getBoolean(property, false);
newButton.setSelected(isSelected);
newButton.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
	boolean selected;
	switch (e.getStateChange()) {
	    case ItemEvent.SELECTED:
		selected = true;
		break;
	    case ItemEvent.DESELECTED:
		selected = false;
		break;
	    default:
		return;
	}
	ResultWindow.getInstance().updateOptionStatus(property, selected);
    }
});
return newButton;
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:StatisticsPanel.java

示例2: showPopup

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * Creates the popup, calculates position and sets focus
 */
private void showPopup(Component source) {

	actionSource = source;
	actionSource.addComponentListener(this);

	if (actionSource instanceof JToggleButton) {
		JToggleButton toggleSource = (JToggleButton) actionSource;
		toggleSource.setSelected(true);
	}

	containingWindow = SwingUtilities.windowForComponent(actionSource);
	containingWindow.addComponentListener(this);

	Point position = calculatePosition(source);
	popupComponent.setLocation(position);
	popupComponent.setVisible(true);
	popup = new ContainerPopupDialog(containingWindow, popupComponent, position);
	popup.setVisible(true);
	popup.requestFocus();
	popupComponent.startTracking(containingWindow, actionSource);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:25,代碼來源:PopupAction.java

示例3: actionPerformed

import javax.swing.JToggleButton; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
	for (JToggleButton button : primaryButtons) {
		if (button != e.getSource() && button.isSelected()) {
			button.setSelected(false);
		} else if (button == e.getSource() && !button.isSelected()) {
			button.setSelected(true);
		}

		if (button.isSelected()) {
			button.setFont(button.getFont().deriveFont(Font.BOLD));
		} else {
			button.setFont(button.getFont().deriveFont(Font.PLAIN));
		}
	}

	if (secondaryButton != null) {
		if (secondaryButton != e.getSource() && secondaryButton.isSelected()) {
			secondaryButton.clearMenuSelection();
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:23,代碼來源:ToggleButtonGroup.java

示例4: SelecioneForAction

import javax.swing.JToggleButton; //導入方法依賴的package包/類
public void SelecioneForAction(Acao ac) {
    if (Barra == null) {
        return;
    }
    for (Component c : Barra.getComponents()) {
        if (c instanceof JToggleButton) {
            JToggleButton btn = (JToggleButton) c;
            javax.swing.Action tmp = btn.getAction();
            if (tmp instanceof Acao) {
                if (((Acao) tmp).IDX == ac.IDX) {
                    btn.setSelected(true);
                }
            }
        }
    }
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:17,代碼來源:Controler.java

示例5: createButtons

import javax.swing.JToggleButton; //導入方法依賴的package包/類
@Override
protected void createButtons(ButtonGroup group) {
    JToggleButton button1 = createOpenViewButton(group, editorView);
    button1.setSelected(true);
    buttonsPanel.add(button1);
    buttonsPanel.add(createOpenViewButton(group, htmlView));
    Iterator<DocBookExporter> iterator = AdditionalPluginLoader
            .loadProviders(DocBookExporter.class);
    while (iterator.hasNext()) {
        final DocBookExporter exporter = iterator.next();
        JButton tb = new JButton();
        tb.setText(exporter.getActionName());
        tb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                exporter.createReport(getFramework(),
                        new ReportLoadCallback() {

                            @Override
                            public InputStream getDocBookInputStream() {
                                // TODO Auto-generated method stub
                                return null;
                            }
                        });
            }
        });
        buttonsPanel.add(tb);
    }
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:31,代碼來源:DocBookScriptReportEditorView.java

示例6: preencher

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * Preencher a janela para escolher o verso do card
 *
 * @param selected verso pré-selecionado. -1 para nenhum verso
 * pré-selecionado.
 */
private void preencher(int selected) {
    for (int i = 0; i < CARDBACK.size(); i++) {
        ImageIcon cardBack = Img.recortar(CARDBACK.get(i).getCardBackImage(), 20, 45, 164, 240);
        cardBack = Img.redimensionaImg(cardBack.getImage(), 0.55);
        JToggleButton button = new JToggleButton(cardBack);
        button.addActionListener(getAction(i));
        button.setBorder(null);
        button.setBackground(new Color(0, 0, 0, 0));
        button.setOpaque(false);
        button.setFocusPainted(false);
        buttonGroup.add(button);
        if (i == selected) {
            button.setBorder(new LineBorder(Color.RED, 2));
            button.setSelected(true);
        }
        jPanelCards.add(button);
    }
}
 
開發者ID:limagiran,項目名稱:hearthstone,代碼行數:25,代碼來源:EscolherCardBack.java

示例7: init

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private void init() {
        initComponents();
        detailsPanel = new JPanel(new GridLayout(1, 1));
        Color color = Utils.getTextBackground();
        detailsPanel.setBackground(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        lblEmptyDetails = new JLabel(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_EmptyDetails"), JLabel.CENTER);
        lblEmptyDetails.setFont(italicFont);
        lblEmptyDetails.setEnabled(false);

        JScrollPane scrollPane = new JScrollPane(detailsPanel);
        splitPane.setRightComponent(scrollPane);

        toolBar.setFocusable(false);
        toolBar.setFloatable(false);
        btnSearch = new JToggleButton(ImageUtilities.loadImageIcon("org/netbeans/modules/notifications/resources/find16.png", true));
        btnSearch.setToolTipText(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_SearchToolTip"));
        btnSearch.setFocusable(false);
        btnSearch.setSelected(NotificationSettings.isSearchVisible());
        //TODO delete 2 lines then quick search API clear text correctly
//        btnSearch.setToolTipText("Disabled due to Quick Search API defects");
//        btnSearch.setEnabled(false);
        btnSearch.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setSearchVisible(btnSearch.isSelected());
            }
        });
        toolBar.add(btnSearch);
        toolBar.add(new FiltersMenuButton(notificationManager.getActiveFilter()));

        initLeft();
        showDetails();
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:NotificationCenterTopComponent.java

示例8: waypointAdded

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * Called when a waypoint is added. This implementation adds a waypoint button.
 * @param graphic the waypoint graphic, whose ID may or may not be populated.
 * @param graphicUid the waypoint graphic's ID.
 * @see RouteListener#waypointAdded(com.esri.core.map.Graphic, int)
 */
public void waypointAdded(Graphic graphic, int graphicUid) {
    final JToggleButton button = new JToggleButton((String) graphic.getAttributeValue("name"));
    waypointButtonToGraphicId.put(button, graphicUid);
    graphicIdToWaypointButton.put(graphicUid, button);
    Font font = new Font("Arial", Font.PLAIN, 18);
    button.setFont(font);
    button.setFocusable(false);
    button.setSelected(false);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (button == selectedWaypointButton) {
                //Unselect
                buttonGroup_waypoints.remove(button);
                button.setSelected(false);
                buttonGroup_waypoints.add(button);
                selectedWaypointButton = null;

                routeController.setSelectedWaypoint(null);
            } else {
                selectedWaypointButton = button;

                routeController.setSelectedWaypoint(waypointButtonToGraphicId.get(button));
            }
        }
    });
    button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
    button.setMinimumSize(new Dimension(0, 60));
    jPanel_waypointsList.add(button);
    buttonGroup_waypoints.add(button);
}
 
開發者ID:Esri,項目名稱:defense-solutions-proofs-of-concept,代碼行數:38,代碼來源:MainMenuJPanel.java

示例9: PopuleBarra

import javax.swing.JToggleButton; //導入方法依賴的package包/類
public void PopuleBarra(JComponent obj) {
    ButtonGroup buttons = new ButtonGroup();
    Barra = obj;

    Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null);
    JToggleButton btn = arrume(new JToggleButton(ac));
    buttons.add(btn);
    obj.add(btn);
    btn.setSelected(true);
    ac.IDX = -1;
    this.BtnNothing = btn;
    int i = 0;
    for (ConfigAcao ca : Lista) {
        if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) {
            ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
            ac.IDX = i++;
            btn = arrume(new JToggleButton(ac));
            buttons.add(btn);
            //obj.add(btn);
            listaBotoes.put(ca.command, btn);
        }
    }
    menuComandos c = menuComandos.cmdDel;
    String str = "Controler.comandos." + c.toString().substring(3).toLowerCase();
    ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString());
    ListaDeAcoesEditaveis.add(ac);
    ac.normal = false;
    JButton btn2 = new JButton(ac);
    btn2.setHideActionText(true);
    btn2.setFocusable(false);
    btn2.setPreferredSize(new Dimension(40, 40));
    obj.add(btn2);

    LayoutManager la = obj.getLayout();
    if (la instanceof GridLayout) {
        ((GridLayout) la).setRows(i + 2);
    }
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:39,代碼來源:Controler.java

示例10: newShowButton

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton newShowButton(String iconId,
                                      String tooltip,
                                      String accessibleName,
                                      Status status) {
    JToggleButton btn = new JToggleButton(ImageUtilities.loadImageIcon(iconId, true));
    btn.setToolTipText(tooltip);
    btn.getAccessibleContext().setAccessibleName(accessibleName);
    btn.setSelected((filterMask & status.getBitMask()) == 0);
    btn.addItemListener(new FilterItemListener(status));
    return btn;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:StatisticsPanel.java

示例11: rebuildToolbar

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private void rebuildToolbar() {
    toolbar.removeAll();
    toolbar.setFocusable( false );
    //scope buttons
    List<TaskScanningScope> scopes = ScanningScopeList.getDefault().getTaskScanningScopes();
    for( TaskScanningScope scope : scopes ) {
        final ScopeButton scopeButton = new ScopeButton( taskManager, scope );
        scopeButton.setSelected(scope.equals(Settings.getDefault().getActiveScanningScope()));
        toolbar.add(scopeButton);
    }
    toolbar.add( new JToolBar.Separator() );
    //filter
    JToggleButton toggleFilter = new FiltersMenuButton( filters.getActive() );
    toolbar.add( toggleFilter );
    //grouping & other butons
    toolbar.addSeparator();
    final JToggleButton toggleGroups = new JToggleButton( ImageUtilities.loadImageIcon("org/netbeans/modules/tasklist/ui/resources/groups.png", false)); //NOI18N
    toggleGroups.addItemListener( new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            switchTableModel( e.getStateChange() == ItemEvent.SELECTED );
            Settings.getDefault().setGroupTasksByCategory( toggleGroups.isSelected() );
            toggleGroups.setToolTipText( toggleGroups.isSelected() 
                    ? NbBundle.getMessage( TaskListTopComponent.class, "HINT_TasksAsList" )  //NOI18N
                    : NbBundle.getMessage( TaskListTopComponent.class, "HINT_GrouppedTasks" ) ); //NOI18N
        }
    });
    toggleGroups.setSelected( Settings.getDefault().getGroupTasksByCategory() );
    toggleGroups.setToolTipText( toggleGroups.isSelected() 
                    ? NbBundle.getMessage( TaskListTopComponent.class, "HINT_TasksAsList" )  //NOI18N
                    : NbBundle.getMessage( TaskListTopComponent.class, "HINT_GrouppedTasks" ) ); //NOI18N
    toggleGroups.setFocusable( false );
    toolbar.add( toggleGroups );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:TaskListTopComponent.java

示例12: setState

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private void setState(boolean state) {
    JToggleButton toggleButton = toggleButtonRef.get();
    if (toggleButton != null) {
        toggleButton.setSelected(state);
    }
    if (state && group != null) {
        for (DVFilter item : group.getItems()) {
            FilterImpl impl = FiltersDescriptor.getInstance().filtersAccessor.getImpl(item);
            if (impl != this && item.isSelected()) {
                item.setSelected(false);
            } // if
        } // for
    } // if
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:FiltersDescriptor.java

示例13: hidePopup

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * Hides the popup component.
 */
private boolean hidePopup() {
	if (actionSource instanceof JToggleButton) {
		JToggleButton toggleSource = (JToggleButton) actionSource;
		toggleSource.setSelected(false);
	}

	if (containingWindow != null) {
		containingWindow.removeComponentListener(this);
		containingWindow = null;
	}

	if (actionSource != null) {
		actionSource.removeComponentListener(this);
		actionSource = null;
	}

	// Check if popup is visible
	if (popup != null) {
		popupComponent.setVisible(false);
		popupComponent.stopTracking();

		// hide popup and reset
		popup.dispose();
		popup = null;

		hideTime = System.currentTimeMillis();
		return true;
	}

	return false;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:35,代碼來源:PopupAction.java

示例14: toggleSelection

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * @param action
 */
protected void toggleSelection(UIOperation op) {
	Iterator i = toggleButtons.values().iterator();
	
	while (i.hasNext()) {
		JToggleButton button = (JToggleButton) i.next();
		
		button.setSelected(false);
		op.setSelected(false);
	}
	
	JToggleButton opButton = (JToggleButton) toggleButtons.get(op);
	opButton.setSelected(true);
	op.setSelected(true);
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:18,代碼來源:OperationsToolBar.java

示例15: setSelectedItem

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * setSelectedItem - sets the ToggleButtonLists selected button.
 *
 * Iterates through all buttons deselecting the ones whoes getText() doesn't
 * match the itemName given in the parameter. If the Item does not match any
 * in the List, selection won't change.
 *
 * @param itemName
 */
public void setSelectedItem(final String itemName) {
    // To avoid not having anything selected at the end
    if (!m_classModel.containsClass(itemName)) {
        return;
    }

    m_selectedItem = itemName;

    String sel;
    if (itemName.equals(ClassModel.NO_CLASS)) {
        sel = m_defaultText;
    } else {
        sel = itemName;
    }

    // iterate through all buttons
    for (final JToggleButton btn : m_buttons) {
        // check whether text matches itemName
        if (btn.getText().equals(sel)) {
            btn.setSelected(true); // it is our item, so select it
        } else {
            btn.setSelected(false); // deselect everything else
        }
        revalidate();
    }

}
 
開發者ID:knime,項目名稱:knime-activelearning,代碼行數:37,代碼來源:ToggleButtonList.java


注:本文中的javax.swing.JToggleButton.setSelected方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。