Example usage for javax.swing JToggleButton JToggleButton

List of usage examples for javax.swing JToggleButton JToggleButton

Introduction

In this page you can find the example usage for javax.swing JToggleButton JToggleButton.

Prototype

public JToggleButton(String text, Icon icon) 

Source Link

Document

Creates a toggle button that has the specified text and image, and that is initially unselected.

Usage

From source file:de.juwimm.cms.content.panel.PanDocuments.java

private JPanel getViewSelectPan() {
    if (panViewSelect == null) {
        panViewSelect = new PanViewSelect();
        panViewSelect.setPreferredSize(new Dimension(26, scrollPane.getHeight()));
        btnListView = new JToggleButton(UIConstants.BTN_LIST_VIEW, true);
        btnListView.setToolTipText(rb.getString("PanDocument.view.list"));
        btnListView.setPreferredSize(new Dimension(UIConstants.BTN_LIST_VIEW.getIconHeight() + 10,
                UIConstants.BTN_LIST_VIEW.getIconWidth() + 10));
        btnSymbolView = new JToggleButton(UIConstants.BTN_SYMBOL_VIEW, false);
        btnSymbolView.setToolTipText(rb.getString("PanDocument.view.symbol"));
        btnSymbolView.setPreferredSize(new Dimension(UIConstants.BTN_SYMBOL_VIEW.getIconHeight() + 10,
                UIConstants.BTN_SYMBOL_VIEW.getIconWidth() + 10));
        btnSymbolView.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Component current = scrollPane.getViewport().getView();
                if (current != null) {
                    scrollPane.getViewport().remove(current);
                }//  w  w w. ja  v a 2s.  com
                scrollPane.getViewport().add(panDocumentButtons, null);
            }
        });
        btnListView.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Component current = scrollPane.getViewport().getView();
                if (current != null) {
                    scrollPane.getViewport().remove(current);
                }
                scrollPane.getViewport().add(tblDocuments, null);
            }
        });
        panViewSelect.addButton(btnListView);
        panViewSelect.addButton(btnSymbolView);
    }
    return panViewSelect;
}

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JToggleButton createViewToggleButton(final String text, final String iconPath) {
    final ImageIcon icon = imageManager.getImageIcon(iconPath);
    final JToggleButton button = new JToggleButton(text, icon);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFont(WidgetUtils.FONT_SMALL);
    button.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST);
    button.setBackground(WidgetUtils.BG_COLOR_DARK);
    button.setBorderPainted(false);//from   w w  w  .j a  va  2s  .  c om
    button.setBorder(new CompoundBorder(WidgetUtils.BORDER_THIN, new EmptyBorder(0, 4, 0, 4)));
    return button;
}

From source file:org.rdv.datapanel.DigitalTabularDataPanel.java

/**
 * Initialize the container and add the header.
 * /*from ww w.j ava2  s  . co m*/
 * @since 1.2
 */
private void initComponents() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    panelBox = Box.createHorizontalBox();

    dataCellRenderer = new DataTableCellRenderer();
    doubleCellRenderer = new DoubleTableCellRenderer();

    showMinMaxCheckBoxGroup = new CheckBoxGroup();
    showThresholdCheckBoxGroup = new CheckBoxGroup();

    addColumn();

    mainPanel.add(panelBox, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());

    JPanel offsetsPanel = new JPanel();

    useOffsetsCheckBox = new JCheckBox("Use Offsets");
    useOffsetsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            boolean checked = ((JCheckBox) ae.getSource()).isSelected();

            useOffsetRenderer(checked);
        }
    });
    offsetsPanel.add(useOffsetsCheckBox);

    JButton takeOffsetsButton = new JButton("Take Offsets");
    takeOffsetsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            useOffsetsCheckBox.setSelected(true); // this moved from above
            // repaint
            for (int i = 0; i < columnGroupCount; i++) {
                ((DataTableModel) tableModels.get(i)).takeOffsets();
                ((DataTableModel) tableModels.get(i)).useOffsets(true);
                ((JTable) tables.get(i)).repaint();
            } // for
        } // actionPerformed ()
    }); // actionlistener
    offsetsPanel.add(takeOffsetsButton);

    buttonPanel.add(offsetsPanel, BorderLayout.WEST);

    JPanel formatPanel = new JPanel();

    decimalButton = new JToggleButton("Decimal", true);
    decimalButton.setSelected(true);
    decimalButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            useEngineeringRenderer(false);
        }
    });
    formatPanel.add(decimalButton);

    engineeringButton = new JToggleButton("Engineering");
    engineeringButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            useEngineeringRenderer(true);
        }
    });
    formatPanel.add(engineeringButton);

    ButtonGroup formatButtonGroup = new ButtonGroup();
    formatButtonGroup.add(decimalButton);
    formatButtonGroup.add(engineeringButton);

    buttonPanel.add(formatPanel, BorderLayout.EAST);

    mainPanel.add(buttonPanel, BorderLayout.SOUTH);

    mainPanel.addMouseListener(new MouseInputAdapter() {
    });

}

From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCToggleButton.java

public TestShowLWTCToggleButton() {
    tdb = new LWTCToggleButton(LWTCControlConstants.STD_TOGGLE_BUTTON_COLOURS, "Kill A", false, false) {
        private static final long serialVersionUID = -359196738631950261L;

        @Override//from ww w.j  ava2  s.c o m
        public void receiveUpdateEvent(final boolean previousValue, final boolean newValue) {
            log.debug("Received update event from " + previousValue + " to " + newValue);
        }
    };
    tdb.setMinimumSize(new Dimension(75, 30));
    otherButton = new JToggleButton("Kill B", false);
    otherButton.setMinimumSize(new Dimension(75, 30));
    final Font f = otherButton.getFont();
    log.debug("Regular button font size = " + f.toString());

    otherButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            log.debug("Received action event: " + e.toString());
        }

    });

    tdb.setSelected(true);
    otherButton.setSelected(true);
}