Example usage for javax.swing JToggleButton addMouseListener

List of usage examples for javax.swing JToggleButton addMouseListener

Introduction

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

Prototype

public synchronized void addMouseListener(MouseListener l) 

Source Link

Document

Adds the specified mouse listener to receive mouse events from this component.

Usage

From source file:io.gameover.utilities.pixeleditor.Pixelizer.java

private void addSelectFrameButtonToPanel(int index) {
    JToggleButton button = new JToggleButton("" + index);
    button.setPreferredSize(new Dimension(20, 20));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setFont(button.getFont().deriveFont(9f));
    button.setActionCommand("" + (index - 1));
    button.addActionListener(getSelectFrameActionListener());
    button.addMouseListener(new SelectFramePopClickListener(this, index - 1));
    this.selectFrameButtons.add(button);
    this.selectFramePanel.add(button,
            LayoutUtils.xyi((index - 1) % 4 + 1, (index - 1) / 4 + 1, 0d, 0d, new Insets(1, 1, 1, 1)));
}

From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java

private void buildMenu() {
    JXTaskPane editPane = new JXTaskPane();
    editPane.setTitle("Bearbeiten");
    final JToggleButton createStats = new JToggleButton(
            new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png")));
    createStats.setToolTipText(//from   ww w.j av a2s  .c  o m
            "Umschalten zwischen dem Erzeugen von Statistiken und der Anzeige von Verlaufsgrafiken");
    createStats.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            boolean showChartView = !createStats.isSelected();
            if (showChartView) {
                createStats
                        .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png")));
            } else {
                createStats
                        .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/chart.png")));
            }
            switchStatChartView(showChartView);
        }
    });

    JXButton selectStart = new JXButton(
            new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/beginning.png")));
    selectStart.setToolTipText("Setzt eine Startmarkierung beim gewhlten Datenpunkt");
    selectStart.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            setStartAnnotation();
        }
    });
    selectStart.setSize(createStats.getSize());
    selectStart.setMinimumSize(createStats.getMinimumSize());
    selectStart.setMaximumSize(createStats.getMaximumSize());
    selectStart.setPreferredSize(createStats.getPreferredSize());
    editPane.getContentPane().add(selectStart);
    JXButton selectEnd = new JXButton(
            new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/end.png")));
    selectEnd.setToolTipText("Setzt eine Endmarkierung beim gewhlten Datenpunkt");
    selectEnd.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            setEndAnnotation();
        }
    });
    selectEnd.setSize(createStats.getSize());
    selectEnd.setMinimumSize(createStats.getMinimumSize());
    selectEnd.setMaximumSize(createStats.getMaximumSize());
    selectEnd.setPreferredSize(createStats.getPreferredSize());
    editPane.getContentPane().add(selectEnd);

    JXButton removeSelection = new JXButton(
            new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/delete_region.png")));
    removeSelection.setToolTipText("Lscht alle Datenpunkte zwischen der Start- und Endmarkierung");
    removeSelection.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            removeSelection();
        }
    });
    removeSelection.setSize(createStats.getSize());
    removeSelection.setMinimumSize(createStats.getMinimumSize());
    removeSelection.setMaximumSize(createStats.getMaximumSize());
    removeSelection.setPreferredSize(createStats.getPreferredSize());
    editPane.getContentPane().add(removeSelection);

    createStats.setSize(removeSelection.getSize());
    createStats.setMinimumSize(removeSelection.getMinimumSize());
    createStats.setMaximumSize(removeSelection.getMaximumSize());
    createStats.setPreferredSize(removeSelection.getPreferredSize());

    editPane.getContentPane().add(createStats);

    JXTaskPane viewPane = new JXTaskPane();
    viewPane.setTitle("Anzeige");
    viewPane.getContentPane().add(jViewSelectionBox);

    JXTaskPane settingsPane = new JXTaskPane();
    settingsPane.setTitle("Einstellungen");

    settingsPane.getContentPane().add(jShowItemValues);
    settingsPane.getContentPane().add(jShowLegend);
    settingsPane.getContentPane().add(jShowLines);
    settingsPane.getContentPane().add(jShowDataPoints);

    centerPanel.setupTaskPane(editPane, viewPane, settingsPane);
}