当前位置: 首页>>代码示例>>Java>>正文


Java JToggleButton.addActionListener方法代码示例

本文整理汇总了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() );
		}
	});
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:20,代码来源:ViewShapes.java

示例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));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:InfoPanel.java

示例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);
	}
}
 
开发者ID:Electro-Light,项目名称:ElectroLight-Intrusion-Detection,代码行数:23,代码来源:ScannersGUI.java

示例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);
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:25,代码来源:EscolherCardBack.java

示例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();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:NotificationCenterTopComponent.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:VariablesViewButtons.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:VariablesViewButtons.java

示例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();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:8,代码来源:XMImage.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:FiltersManager.java

示例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();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:8,代码来源:SCSImage2.java

示例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);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:48,代码来源:ToggleButtonGroup.java

示例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;
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:36,代码来源:Digitizer.java

示例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);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:38,代码来源:MainMenuJPanel.java

示例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;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:8,代码来源:TestSetToolBar.java

示例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;
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:FiltersManagerImpl.java


注:本文中的javax.swing.JToggleButton.addActionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。