Search in sources :

Example 41 with JToggleButton

use of javax.swing.JToggleButton in project ACS by ACS-Community.

the class BeanGrouper method getPauseButton.

/**
	 * This method pause the graphic in movement<br>
	 * This JButton when click do a pause of the graphic, but the sampling still running<br>
	 * @return javax.swing.JButton Reference to the Pause Button.
	 */
private JToggleButton getPauseButton() {
    if (pauseButton == null) {
        pauseButton = new JToggleButton();
        pauseButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("cl/utfsm/samplingSystemUI/img/player_pause.png")));
        pauseButton.setToolTipText("Pause the graphic.");
        pauseButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (pausedGraph == false) {
                    for (DataPrinter i : samplers) {
                        i.pauseSampling(true);
                    }
                    pauseButton.setSelected(true);
                    pausedGraph = true;
                } else {
                    for (DataPrinter i : samplers) {
                        i.pauseSampling(false);
                    }
                    pausedGraph = false;
                    pauseButton.setSelected(false);
                }
            }
        });
    }
    return pauseButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) JToggleButton(javax.swing.JToggleButton) ActionEvent(java.awt.event.ActionEvent)

Example 42 with JToggleButton

use of javax.swing.JToggleButton in project ChatGameFontificator by GlitchCog.

the class ControlPanelDebug method build.

@Override
protected void build() {
    postTestMessage = new JButton("Post Debug Message");
    postTestMessage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ctrlWindow.addManualMessage("Test", SpriteFont.NORMAL_ASCII_KEY);
        }
    });
    postMessagesButton = new JToggleButton("Post Messages");
    postRateSlider = new LabeledSlider("Post Rate ", " / min", 1, 120, 15, 3);
    postClock = new Timer(60000 / postRateSlider.getValue(), new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            postRandomMessage();
        }
    });
    postRateSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
                postClock.setDelay(60000 / postRateSlider.getValue());
                if (postClock.isRunning()) {
                    postRandomMessage();
                    postClock.restart();
                }
            }
        }
    });
    postMessagesButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            postRandomMessage();
            if (postMessagesButton.isSelected()) {
                postClock.start();
            } else {
                postClock.stop();
            }
        }
    });
    drawTextGridBox = new JCheckBox("Draw Text Grid");
    textGridColorButton = new ColorButton("Text Grid Color", new Color(0x99FF88), "Color of the border grid", this);
    drawBorderGridBox = new JCheckBox("Draw Border Grid");
    borderGridColorButton = new ColorButton("Border Grid Color", new Color(0x9988FF), "Color of the border grid", this);
    ActionListener refreshListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (chat != null) {
                chat.repaint();
            }
        }
    };
    drawTextGridBox.addActionListener(refreshListener);
    drawBorderGridBox.addActionListener(refreshListener);
    JPanel topPanel = new JPanel(new GridBagLayout());
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    topPanel.add(postTestMessage, gbc);
    gbc.gridx++;
    topPanel.add(postMessagesButton, gbc);
    gbc.gridx++;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    topPanel.add(postRateSlider, gbc);
    gbc.gridwidth = 4;
    gbc.gridx = 0;
    gbc.gridy = 0;
    add(topPanel, gbc);
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(drawTextGridBox, gbc);
    gbc.gridx++;
    add(textGridColorButton, gbc);
    gbc.gridx++;
    add(drawBorderGridBox, gbc);
    gbc.gridx++;
    add(borderGridColorButton, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.weighty = 0.1;
    CollagePanel collagePanel = new CollagePanel(chat);
    add(collagePanel, gbc);
    gbc.gridy++;
    gbc.weightx = 1.0;
    gbc.weighty = 0.9;
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = 4;
    add(logBox, gbc);
}
Also used : JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) Color(java.awt.Color) JButton(javax.swing.JButton) JCheckBox(javax.swing.JCheckBox) LabeledSlider(com.glitchcog.fontificator.gui.component.LabeledSlider) ActionListener(java.awt.event.ActionListener) JToggleButton(javax.swing.JToggleButton) Timer(javax.swing.Timer) ChangeEvent(javax.swing.event.ChangeEvent) ColorButton(com.glitchcog.fontificator.gui.component.ColorButton) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener)

Example 43 with JToggleButton

use of javax.swing.JToggleButton in project ChatGameFontificator by GlitchCog.

the class CharacterPicker method build.

private void build() {
    setLayout(new GridLayout(12, 8));
    setTitle("Character Picker");
    ActionListener al = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JToggleButton tb = (JToggleButton) e.getSource();
            setSelectedChar(tb.getText().charAt(0));
            setVisible(false);
        }
    };
    buttonGroup = new ButtonGroup() {

        private static final long serialVersionUID = 1L;

        @Override
        public void setSelected(ButtonModel model, boolean selected) {
            if (selected) {
                super.setSelected(model, selected);
            } else {
                clearSelection();
            }
        }
    };
    charButtons = new JToggleButton[96];
    for (int i = 0; i < charButtons.length; i++) {
        charButtons[i] = new JToggleButton(Character.toString((char) (i + 32)));
        charButtons[i].addActionListener(al);
        buttonGroup.add(charButtons[i]);
        add(charButtons[i]);
    }
    pack();
    setResizable(false);
}
Also used : GridLayout(java.awt.GridLayout) ActionListener(java.awt.event.ActionListener) JToggleButton(javax.swing.JToggleButton) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) ButtonModel(javax.swing.ButtonModel)

Example 44 with JToggleButton

use of javax.swing.JToggleButton in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 45 with JToggleButton

use of javax.swing.JToggleButton in project logging-log4j2 by apache.

the class ClientGui method scroll.

private JScrollPane scroll(final JTextArea text) {
    final JToggleButton toggleButton = new JToggleButton();
    toggleButton.setAction(new AbstractAction() {

        private static final long serialVersionUID = -4214143754637722322L;

        @Override
        public void actionPerformed(final ActionEvent e) {
            final boolean wrap = toggleButton.isSelected();
            text.setLineWrap(wrap);
        }
    });
    toggleButton.setToolTipText("Toggle line wrapping");
    final JScrollPane scrollStatusLog = new //
    JScrollPane(//
    text, //
    ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollStatusLog.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, toggleButton);
    return scrollStatusLog;
}
Also used : JScrollPane(javax.swing.JScrollPane) JToggleButton(javax.swing.JToggleButton) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Aggregations

JToggleButton (javax.swing.JToggleButton)59 ActionEvent (java.awt.event.ActionEvent)21 ActionListener (java.awt.event.ActionListener)21 ImageIcon (javax.swing.ImageIcon)20 JPanel (javax.swing.JPanel)19 JLabel (javax.swing.JLabel)16 Dimension (java.awt.Dimension)14 JButton (javax.swing.JButton)13 Insets (java.awt.Insets)11 JScrollPane (javax.swing.JScrollPane)8 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)8 GridBagLayout (java.awt.GridBagLayout)7 BoxLayout (javax.swing.BoxLayout)7 GridBagConstraints (java.awt.GridBagConstraints)6 JCheckBox (javax.swing.JCheckBox)6 JSlider (javax.swing.JSlider)6 JTabbedPane (javax.swing.JTabbedPane)6 Component (java.awt.Component)5 GridLayout (java.awt.GridLayout)5