本文整理匯總了Java中javax.swing.JToggleButton.addActionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JToggleButton.addActionListener方法的具體用法?Java JToggleButton.addActionListener怎麽用?Java JToggleButton.addActionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JToggleButton
的用法示例。
在下文中一共展示了JToggleButton.addActionListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initToggle
import javax.swing.JToggleButton; //導入方法依賴的package包/類
void initToggle() {
shapeToggle = new JToggleButton(Icons.getIcon(Icons.POLYGON, false));
shapeToggle.setSelectedIcon(Icons.getIcon(Icons.POLYGON, true));
shapeToggle.setBorder( null );
shapeToggle.setToolTipText("Shapefile Manager");
shapeToggle.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
if( shapeToggle.isSelected() ) {
// if( suite.getShapes().size()==0 ) {
if( table==null ) {
init();
// shapeToggle.setSelected(false);
return;
}
}
dialog.setVisible( shapeToggle.isSelected() );
}
});
}
示例2: createFilterToolBarUI
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private void createFilterToolBarUI(JToolBar toolbar, FiltersDescriptor filtersDesc) {
toolbar.removeAll();
// create toggle buttons
int filterCount = filtersDesc.getFilterCount();
ArrayList<JToggleButton> toggles = new ArrayList<JToggleButton>(filterCount);
JToggleButton toggleButton = null;
for (int i = 0; i < filterCount; i++) {
toggleButton = createToggle(filtersDesc, i);
toggles.add(toggleButton);
}
// add toggle buttons
for (int i = 0; i < toggles.size(); i++) {
JToggleButton curToggle = toggles.get(i);
curToggle.addActionListener(new ToggleButtonActionListener(i));
toolbar.add(curToggle);
if (i != toggles.size() - 1) {
toolbar.addSeparator(new Dimension(3, 0));
}
}
}
示例3: ScannersGUI
import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
* Create the panel.
*/
public ScannersGUI() {
Scanner s;
for (String ss : ScannersManager.getInstance().getScanners().keySet()) {
s = ScannersManager.getInstance().getScanners().get(ss);
JToggleButton btn = new JToggleButton(s.getName(), s.isStarted());
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (btn.isSelected()) {
ScannersManager.getInstance().getScanners().get(btn.getText()).onStart();
} else {
ScannersManager.getInstance().getScanners().get(btn.getText()).onStop();
}
}
});
add(btn);
}
}
示例4: 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);
}
}
示例5: 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();
}
示例6: createShowWatchesButton
import javax.swing.JToggleButton; //導入方法依賴的package包/類
public static JToggleButton createShowWatchesButton() {
JToggleButton button = createToggleButton(
SHOW_WATCHES,
"org/netbeans/modules/debugger/resources/localsView/show_watches_16.png",
NbBundle.getMessage (VariablesViewButtons.class, "Hint_Show_Watches")
);
button.addActionListener(new ShowWatchesActionListener(button));
return button;
}
示例7: createShowResultButton
import javax.swing.JToggleButton; //導入方法依賴的package包/類
public static JToggleButton createShowResultButton() {
JToggleButton button = createToggleButton(
SHOW_EVALUTOR_RESULT,
"org/netbeans/modules/debugger/resources/localsView/show_evaluator_result_16.png",
NbBundle.getMessage (VariablesViewButtons.class, "Hint_Show_Result")
);
button.addActionListener(new ShowResultActionListener(button));
return button;
}
示例8: ToggleToggler
import javax.swing.JToggleButton; //導入方法依賴的package包/類
public ToggleToggler(JToggleButton b,JToggleButton no) {
this.b=b;
this.no=no;
b.addActionListener(this);
b.addChangeListener(this);
wasSelected=b.isSelected();
}
示例9: initPanel
import javax.swing.JToggleButton; //導入方法依賴的package包/類
/** Called only from AWT */
private void initPanel () {
setBorder(new EmptyBorder(1, 2, 3, 5));
// configure toolbar
JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
toolbar.setFloatable(false);
toolbar.setRollover(true);
toolbar.setBorderPainted(false);
// create toggle buttons
int filterCount = filtersDesc.getFilterCount();
toggles = new ArrayList<JToggleButton>(filterCount);
JToggleButton toggleButton = null;
Map<String,Boolean> fStates = new HashMap<String, Boolean>(filterCount * 2);
for (int i = 0; i < filterCount; i++) {
toggleButton = createToggle(fStates, i);
toggles.add(toggleButton);
}
// add toggle buttons
JToggleButton curToggle;
Dimension space = new Dimension(3, 0);
for (int i = 0; i < toggles.size(); i++) {
curToggle = toggles.get(i);
curToggle.addActionListener(this);
toolbar.add(curToggle);
if (i != toggles.size() - 1) {
toolbar.addSeparator(space);
}
}
add(toolbar);
// initialize member states map
synchronized (STATES_LOCK) {
filterStates = fStates;
}
}
示例10: ToggleToggler
import javax.swing.JToggleButton; //導入方法依賴的package包/類
public ToggleToggler(JToggleButton b,JToggleButton no){
this.b=b;
this.no=no;
b.addActionListener(this);
b.addChangeListener(this);
wasSelected=b.isSelected();
}
示例11: ToggleButtonGroup
import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
* Creates a new button group from the given Actions (requires at least two actions).
*
* @param preferredSize
* the preferredSize of the nested {@link CompositeToggleButton}s or {@code null}
* @param actions
* the action
*/
public ToggleButtonGroup(Dimension preferredSize, Action... actions) {
if (actions.length < 2) {
throw new IllegalArgumentException("At least two primary actions must be specified.");
}
this.setOpaque(false);
this.preferredSize = preferredSize;
primaryButtons = new CompositeToggleButton[actions.length];
for (int i = 0; i < actions.length; i++) {
int position;
if (i == 0) {
position = SwingConstants.LEFT;
} else if (i < actions.length - 1) {
position = SwingConstants.CENTER;
} else {
position = SwingConstants.RIGHT;
}
primaryButtons[i] = new CompositeToggleButton(actions[i], position);
}
// align buttons left to right with no padding
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weighty = 1;
for (JToggleButton button : primaryButtons) {
button.addActionListener(buttonChooser);
if (preferredSize != null) {
button.setMinimumSize(preferredSize);
button.setPreferredSize(preferredSize);
}
add(button, gbc);
}
}
示例12: initTools
import javax.swing.JToggleButton; //導入方法依賴的package包/類
void initTools() {
tools = new JPanel(new BorderLayout());
tools.setMinimumSize(new Dimension(200, tools.getMinimumSize().height));
tools.setPreferredSize(new Dimension(200, tools.getPreferredSize().height));
JPanel panel = new JPanel(new GridLayout(0,1));
helpBtn = new JButton("Help");
helpBtn.addActionListener(this);
panel.add(helpBtn);
startStopBtn = new JToggleButton("Start digitizing");
startStopBtn.addActionListener(this);
startStopBtn.setForeground(new Color(0,128,0));
panel.add(startStopBtn);
deleteBtn = new JButton("Delete segment(s)");
deleteBtn.addActionListener(this);
panel.add(deleteBtn);
addBtn = new JButton("Add to segment");
addBtn.addActionListener(this);
addBtn.setEnabled(false);
panel.add(addBtn);
objectClasses = new Class[2];
objectClasses[0] = null;
tools.add( panel, "North" );
tools.add( new JScrollPane( list ), "Center");
try {
objectClasses[1] = Class.forName( "haxby.db.dig.LineSegmentsObject" );
} catch( Exception ex) {
ex.printStackTrace();
objectClasses[1] = null;
}
}
示例13: 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);
}
示例14: createToggleButton
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton createToggleButton() {
JToggleButton console = new JToggleButton(Utils.getIconByResourceName("/ui/resources/toolbar/console"));
console.setActionCommand("Console");
console.setToolTipText("Show/Hide Console Box");
console.addActionListener(actionListener);
return console;
}
示例15: initPanel
import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
* Called only from AWT
*/
private void initPanel() {
// configure toolbar
toolbar = new ToolbarWithOverflow(JToolBar.VERTICAL);
toolbar.setFloatable(false);
toolbar.setRollover(true);
toolbar.setBorderPainted(true);
toolbar.setBorder(
javax.swing.BorderFactory.createCompoundBorder(
javax.swing.BorderFactory.createMatteBorder(0, 1, 0, 0,
javax.swing.UIManager.getDefaults().getColor("Separator.foreground")), //NOI18N
javax.swing.BorderFactory.createEmptyBorder(0, 1, 0, 0)));
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
toolbar.setBackground(UIManager.getColor("NbExplorerView.background"));
}
// toolbar.setFocusable(false);
// create toggle buttons
int filterCount = filtersDesc.getFilterCount();
toggles = new ArrayList<JToggleButton>(filterCount);
JToggleButton toggleButton;
Map<String, Boolean> fStates = new HashMap<String, Boolean>(filterCount * 2);
for (int i = 0; i < filterCount; i++) {
toggleButton = createToggle(fStates, i);
toggles.add(toggleButton);
}
// add toggle buttons
JToggleButton curToggle;
for (int i = 0; i < toggles.size(); i++) {
curToggle = toggles.get(i);
curToggle.addActionListener(this);
toolbar.add(curToggle);
}
// initialize member states map
synchronized (STATES_LOCK) {
filterStates = fStates;
}
}