Search in sources :

Example 1 with JToggleButton

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

the class BeanGrouper method getSaveButton.

private JToggleButton getSaveButton() {
    if (saveButton == null) {
        saveButton = new JToggleButton();
        saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("cl/utfsm/samplingSystemUI/img/filesave.png")));
        saveButton.setSelected(false);
        saveButton.setToolTipText("Press to start saving sampled data to file");
        saveButton.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                if (saveButton.isSelected() == true) {
                    saveButton.setToolTipText("Press to stop saving sampled data to file");
                    for (DataPrinter dp : samplers) {
                        ((PlotPrinter) dp).setDumpToFile(true);
                    }
                } else {
                    saveButton.setToolTipText("Press to start saving sampled data to file");
                    for (DataPrinter dp : samplers) {
                        ((PlotPrinter) dp).setDumpToFile(false);
                    }
                }
            }
        });
    }
    return saveButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) JToggleButton(javax.swing.JToggleButton) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 2 with JToggleButton

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

the class Toolbar method initialize.

/**
	 * Initialize the toolbar
	 * 
	 * @param <code>true</code> if the reduction rules are applied at startup
	 */
private void initialize(boolean reduce) {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    // Add the button to inhibit sounds
    add(soundComponent);
    // Add the label and the combobox for auto ack
    Font fnt = autoAckLbl.getFont();
    Font newFont = fnt.deriveFont(fnt.getSize() * 80 / 100);
    autoAckLbl.setFont(newFont);
    add(Box.createHorizontalStrut(2));
    add(autoAckLbl);
    autoAckLevelCB.setFont(newFont);
    autoAckLevelCB.setEditable(false);
    autoAckLevelCB.setOpaque(true);
    // Set the colors of the renderers
    ComboBoxValues.initSizes();
    autoAckLevelCB.setRenderer(new ComboBoxRenderer());
    autoAckLevelCB.setSelectedIndex(ComboBoxValues.NONE.ordinal());
    autoAckLevelCB.setMaximumRowCount(ComboBoxValues.values().length);
    autoAckLevelCB.setEditable(false);
    autoAckLevelCB.addActionListener(this);
    Dimension d = new Dimension(ComboBoxValues.getWidth(), ComboBoxValues.getHeight());
    autoAckLevelCB.setMinimumSize(d);
    add(Box.createHorizontalStrut(5));
    add(autoAckLevelCB);
    activeReductionIcon = new ImageIcon(this.getClass().getResource("/alma/acsplugins/alarmsystem/gui/resources/arrow_in.png"));
    inactiveReductionIcon = new ImageIcon(this.getClass().getResource("/alma/acsplugins/alarmsystem/gui/resources/arrow_out.png"));
    reductionRulesBtn = new JToggleButton("Reduce", activeReductionIcon, reduce);
    reductionRulesBtn.setFont(newFont);
    add(Box.createHorizontalStrut(5));
    add(reductionRulesBtn);
    reductionRulesBtn.addActionListener(this);
    add(Box.createHorizontalStrut(5));
    add(pauseBtn);
    pauseBtn.addActionListener(this);
    pauseBtn.setFont(newFont);
    add(Box.createHorizontalStrut(5));
    add(new JSeparator(JSeparator.VERTICAL));
    add(Box.createHorizontalStrut(5));
    JLabel searchLbl = new JLabel("Search");
    add(searchLbl);
    searchLbl.setFont(newFont);
    add(Box.createHorizontalStrut(5));
    add(searchTF);
    searchTF.setEditable(true);
    searchTF.getDocument().addDocumentListener(this);
    searchTF.setToolTipText("Search");
    add(Box.createHorizontalStrut(3));
    add(prevSearchBtn);
    prevSearchBtn.setToolTipText("Search prev");
    prevSearchBtn.addActionListener(this);
    add(Box.createHorizontalStrut(3));
    add(nextSearchBtn);
    nextSearchBtn.setToolTipText("Search next");
    nextSearchBtn.addActionListener(this);
    add(Box.createHorizontalStrut(3));
    add(showBtn);
    showBtn.setFont(newFont);
    showBtn.setToolTipText("Filter in");
    showBtn.addActionListener(this);
    add(Box.createHorizontalStrut(3));
    add(hideBtn);
    hideBtn.setFont(newFont);
    hideBtn.setToolTipText("Filter out");
    hideBtn.addActionListener(this);
    add(Box.createHorizontalStrut(2));
    ratioSearchBtns();
}
Also used : ImageIcon(javax.swing.ImageIcon) JToggleButton(javax.swing.JToggleButton) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Font(java.awt.Font) JSeparator(javax.swing.JSeparator)

Example 3 with JToggleButton

use of javax.swing.JToggleButton in project zaproxy by zaproxy.

the class SpiderPanel method getShowMessagesToggleButton.

private JToggleButton getShowMessagesToggleButton() {
    if (showMessageToggleButton == null) {
        showMessageToggleButton = new JToggleButton(Constant.messages.getString("spider.toolbar.button.showmessages.label"), new ImageIcon(SpiderPanel.class.getResource("/resource/icon/16/178.png")));
        showMessageToggleButton.setToolTipText(Constant.messages.getString("spider.toolbar.button.showmessages.tooltip"));
        showMessageToggleButton.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (ItemEvent.SELECTED == e.getStateChange()) {
                    showTabs();
                } else {
                    hideMessagesTab();
                }
            }
        });
    }
    return showMessageToggleButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) ItemEvent(java.awt.event.ItemEvent) JToggleButton(javax.swing.JToggleButton) ItemListener(java.awt.event.ItemListener)

Example 4 with JToggleButton

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

the class Test6817933 method main.

public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception exception) {
        exception.printStackTrace();
        // ignore test on non-Windows machines
        return;
    }
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            StyleSheet css = new StyleSheet();
            css.addRule(STYLE);
            HTMLEditorKit kit = new HTMLEditorKit();
            kit.setStyleSheet(css);
            JFrame frame = new JFrame(STYLE);
            frame.add(chooser = new JFileChooser());
            frame.setSize(640, 480);
            frame.setVisible(true);
        }
    });
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.realSync(500);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            try {
                JToggleButton button = get(JToggleButton.class, get(WindowsPlacesBar.class, chooser));
                int width = button.getWidth();
                int height = button.getHeight() / 3;
                Point point = new Point(0, height * 2);
                SwingUtilities.convertPointToScreen(point, button);
                width += point.x;
                height += point.y;
                int count = 0;
                Robot robot = new Robot();
                for (int x = point.x; x < width; x++) {
                    for (int y = point.y; y < height; y++) {
                        count += COLOR.equals(robot.getPixelColor(x, y)) ? -2 : 1;
                    }
                }
                if (count < 0) {
                    throw new Exception("TEST ERROR: a lot of red pixels");
                }
            } catch (Exception exception) {
                throw new Error(exception);
            } finally {
                SwingUtilities.getWindowAncestor(chooser).dispose();
            }
        }
    });
}
Also used : StyleSheet(javax.swing.text.html.StyleSheet) JFileChooser(javax.swing.JFileChooser) JToggleButton(javax.swing.JToggleButton) JFrame(javax.swing.JFrame) SunToolkit(sun.awt.SunToolkit) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Point(java.awt.Point) Robot(java.awt.Robot)

Example 5 with JToggleButton

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

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    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()); --> don't test defines max and min in
    // terms of preferred
    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) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

JToggleButton (javax.swing.JToggleButton)179 ActionEvent (java.awt.event.ActionEvent)92 ActionListener (java.awt.event.ActionListener)90 ImageIcon (javax.swing.ImageIcon)76 Dimension (java.awt.Dimension)69 JPanel (javax.swing.JPanel)58 JButton (javax.swing.JButton)46 JLabel (javax.swing.JLabel)39 Point (java.awt.Point)29 JScrollPane (javax.swing.JScrollPane)19 BorderLayout (java.awt.BorderLayout)17 ChangeEvent (javax.swing.event.ChangeEvent)15 Insets (java.awt.Insets)14 ItemEvent (java.awt.event.ItemEvent)14 ChangeListener (javax.swing.event.ChangeListener)14 ItemListener (java.awt.event.ItemListener)13 Component (java.awt.Component)12 FlowLayout (java.awt.FlowLayout)12 BoxLayout (javax.swing.BoxLayout)12 JToolBar (javax.swing.JToolBar)12