Java 8 JToggleButton - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JToggleButton class.

This code example shows how to use the following methods:isSelected, setSelected, setText, setForeground
 
    @Override 
    public void actionPerformed(ActionEvent e) {
        try { 
            if (e.getSource() == mField) {
                boolean value = mField.isSelected();
                setValue(value);
                readValue(); 
            } else if (e.getSource() == mBtnTurnOn) {
                setValue(true); 
            } else if (e.getSource() == mBtnTurnOff) {
                setValue(false); 
            } 
        } catch (IOException e1) {
            e1.printStackTrace();
        } 
    } 
 
    private void setValue(boolean value) throws IOException {
        mItem.sendBoolValueToServer(value, createPacket());

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isVisible, isSelected, setSelected
 
		initializeComponents(); 
 
		titlePanel.addMouseListener(new MouseAdapter() {
			public void mouseClicked (MouseEvent event) {
				if (!activeButton.isVisible()) return;
				activeButton.setSelected(!activeButton.isSelected());
				updateActive(); 
			} 
		}); 
		activeButton.addActionListener(new ActionListener() {
			public void actionPerformed (ActionEvent event) {
				updateActive(); 
			} 
		}); 
		advancedButton.addActionListener(new ActionListener() {
			public void actionPerformed (ActionEvent event) {
				advancedPanel.setVisible(advancedButton.isSelected());
			} 
		}); 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addActionListener, isSelected, setSelected
    public IntPropertyView(Item item, Packet in, XAppDbgConnection connection) throws IOException {
        super(item, in.getChannel(), connection);
 
        // Setup UI 
        if (item.isReadable()) {
            btnHex = new JToggleButton("H");
            add(btnHex, BorderLayout.EAST);
            btnHex.addActionListener(this);
            btnHex.setSelected(false);
        } 
 
        mField = new JTextField();
        mField.setDisabledTextColor(Color.DARK_GRAY);
        add(mField, BorderLayout.CENTER);
        mField.addKeyListener(this);
        mField.setToolTipText(item.getDescription());
 
        if (item.isReadable()) {
            // Read initial value 
            mCachedValue = mOrigValue = in.readInt();

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setEnabled, setSelected, setText
    public StringPropertyView(Item item, Packet in, XAppDbgConnection connection) throws IOException {
        super(item, in.getChannel(), connection);
 
        // Setup UI 
        if (item.isReadable()) {
            mBtnNull = new JToggleButton("");
            add(mBtnNull, BorderLayout.EAST);
            mBtnNull.addActionListener(this);
            mBtnNull.setSelected(false);
        } else { 
            mBtnSetNull = new JButton("Set NULL");
            add(mBtnSetNull, BorderLayout.EAST);
            mBtnSetNull.addActionListener(this);
        } 
 
        mField = new JTextField();
        mField.setDisabledTextColor(Color.DARK_GRAY);
        add(mField, BorderLayout.CENTER);
        mField.addKeyListener(this);
        mField.setToolTipText(item.getDescription());

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getName, getIcon, getToolTipText
	public DrawingAction(MeasurementViewer model, JToggleButton button)
	{ 
		super(model);
		if (button == null)
			throw new IllegalArgumentException("No button specified. ");
		putValue(Action.NAME, button.getName());
		putValue(Action.SHORT_DESCRIPTION, 
                UIUtilities.formatToolTipText(button.getToolTipText()));
		//resize icons 
		Icon icon = button.getIcon();
		if (icon != null) putValue(Action.SMALL_ICON, Factory.scaleIcon(icon));
	} 
	 
	/**  
	 * Removes the action listener. 
     * @see java.awt.event.ActionListener#actionPerformed(ActionEvent) 
     */ 
    public void actionPerformed(ActionEvent e) {}
     
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSelected, getPreferredSize, setPreferredSize
            boolean selected, boolean expanded, boolean leaf, int row, 
            boolean hasFocus)
    { 
        setEnabled(tree.isEnabled());
        if (restoredSize == null) {
        	restoredSize = new Dimension(check.getPreferredSize().width, 
        								DEFAULT_HEIGHT);
        } 
        TreeCheckNode node = (TreeCheckNode) value;
        check.setSelected(node.isSelected());
        label.setFont(tree.getFont());
        label.setText(node.toString());
        label.setSelected(selected);
        label.setFocus(hasFocus);
        Icon nodeIcon = node.getNodeIcon();
        if (node.isLeafNode()) {
            if (nodeIcon == null) nodeIcon = UIManager.getIcon("Tree.leafIcon");
            check.setPreferredSize(restoredSize);
            add(check);
            add(label);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	public JSpinner movementSpeed;
	public JToggleButton movementPlayPause;
	public JToggleButton playPause;
 
	public ControlPanel() { 
		flip = new JToggleButton("Horizontal spiegeln");
		animationChooser = new JComboBox();
		playPause = new JToggleButton(new ImageIcon(ClassLoader.getSystemResource("de/fhtrier/gdig/tools/spriteviewer/icons/pause.png")));
		movementPlayPause = new JToggleButton(new ImageIcon(ClassLoader.getSystemResource("de/fhtrier/gdig/tools/spriteviewer/icons/play.png")));
		animationSpeed = new JSpinner(new SpinnerNumberModel(100, 1, 10000, 1));
		movementSpeed = new JSpinner(new SpinnerNumberModel(100, -10000, 10000, 1));
 
		JLabel animationLabel = new JLabel("Animation:");
		JLabel animationSpeedLabel = new JLabel("Animationsdelay:");
		JLabel movementSpeedLabel = new JLabel("Bewegungsgeschwindigkeit:");
		 
		GroupLayout gl = new GroupLayout(this);
		gl.setHorizontalGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING, false)
				.addGroup(gl.createSequentialGroup().addComponent(flip))
				.addGroup(gl.createSequentialGroup().addComponent(animationLabel))				

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setEnabled, setToolTipText
     * @param toolTip the tool tip text 
     * @param action the action for the button 
     * @param isMenuButton true if the button will have a menu 
     */ 
    protected JToggleButton makeToggleButton(String toolTip, Action action) {
        JToggleButton button = new JToggleButton();
        button.setToolTipText(toolTip);
        if (action != null) {
            action.addPropertyChangeListener(new ButtonPropertyChangeListener(button));
            button.setEnabled(action.isEnabled());
            button.addActionListener(action);
        } 
        setupButton(button);
 
        return button;
    } 
 
 
    /** 
     * Make and return a menu button with the given tool tip and menu. 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setModel, setText, setToolTipText
     * Creates and returns a normal button using this model. 
     * 
     * @return  button 
     */ 
    public JToggleButton createButton() {
        JToggleButton button = new JToggleButton( text_, icon_ );
        button.setModel( this );
        button.setToolTipText( shortdesc_ );
        return button;
    } 
 
    /** 
     * Creates and returns a button suitable for use in a toolbar using 
     * this model.   The button has no text. 
     * 
     * @return  button  
     */ 
    public JToggleButton createToolbarButton() {
        JToggleButton button = createButton();
        button.setText( null );

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isSelected
    } 
     
    protected String[] getFieldValues() {
        JToggleButton button = (JToggleButton) getComponent();
         
        if (button.isSelected()) {
            return new String [] {
                    hasAttribute("value") ? getAttribute("value") : "on" 
            }; 
        } else { 
            return new String[] {};
        } 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 JToggleButton Methods: