Example usage for java.awt.event MouseEvent BUTTON3

List of usage examples for java.awt.event MouseEvent BUTTON3

Introduction

In this page you can find the example usage for java.awt.event MouseEvent BUTTON3.

Prototype

int BUTTON3

To view the source code for java.awt.event MouseEvent BUTTON3.

Click Source Link

Document

Indicates mouse button #3; used by #getButton .

Usage

From source file:com.qawaa.gui.PointAnalysisGUI.java

/**
* Auto-generated main method to display this JFrame
*///from   w w  w  .j  av a2s  .  co m
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            PointAnalysisGUI inst = new PointAnalysisGUI();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
            inst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            FlowLayout flowLayout = new FlowLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            flowLayout.setAlignOnBaseline(true);
            inst.setTitle(PROGRAM_NAME + " [" + PROGRAM_VERSION + "] " + " - " + DefaultMessage.SOFT_NAME
                    + " - " + DefaultMessage.COMPANY_NAME);
            {
                consoleScrollPane = new JScrollPane();
                inst.getContentPane().add(consoleScrollPane, BorderLayout.CENTER);
                {
                    consolePane = new JEditorPane();
                    consoleScrollPane.setViewportView(consolePane);
                    consolePane.setText("");
                    setConsoleRight();
                    jConsole = new JConsole(System.out, consolePane);
                    System.setOut(jConsole);
                    System.setErr(jConsole);
                    consolePane.setEditable(false);
                    consolePane.addMouseListener(new MouseAdapter() {
                        /* (non-Javadoc)
                         * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
                         */
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                consolePane.add(consoleRight);
                                consoleRight.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    });
                }
            }
            {
                infoPanel = new JPanel();
                inst.getContentPane().add(infoPanel, BorderLayout.SOUTH);
                infoPanel.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                infoPanel.setPreferredSize(new Dimension(784, 30));
                infoPanel.setLayout(flowLayout);
                {
                    {
                        statusbar_count = new JTextPane();
                        infoPanel.add(statusbar_count);
                        statusbar_count
                                .setText(CONTEXT.getMessage("point.statusbar.count", null, Locale.CHINA));
                        statusbar_count.setBackground(null);
                        statusbar_count.setEditable(false);
                    }
                    {
                        statusbar_count_value = new JTextPane();
                        infoPanel.add(statusbar_count_value);
                        statusbar_count_value.setText(String.valueOf(SCAN_COUNT));
                        statusbar_count_value.setBackground(null);
                        statusbar_count_value.setEditable(false);
                        statusbar_count_value.setEnabled(false);
                    }
                    {
                        programPID = new JTextPane();
                        infoPanel.add(programPID);
                        programPID.setText("PID:");
                        programPID.setBackground(null);
                        programPID.setEditable(false);
                    }
                    {
                        programPID_value = new JTextPane();
                        infoPanel.add(programPID_value);
                        programPID_value.setText(JvmPid.getPID());
                        programPID_value.setBackground(null);
                        programPID_value.setEditable(false);
                        programPID_value.setEnabled(false);
                    }
                    {
                        memory = new JTextPane();
                        infoPanel.add(memory);
                        memory.setText(CONTEXT.getMessage("gobal.gui.memory", null, Locale.CHINA));
                        memory.setBackground(null);
                        memory.setEditable(false);
                    }
                    {
                        memory_value = new JTextPane();
                        infoPanel.add(memory_value);
                        memory_value.setText("0KB");
                        memory_value.setBackground(null);
                        memory_value.setEditable(false);
                        memory_value.setEnabled(false);
                        MemoryListener memory = new MemoryListener(memory_value);
                        memory.start();
                    }
                    {
                        runtime = new JTextPane();
                        infoPanel.add(runtime);
                        runtime.setText(CONTEXT.getMessage("gobal.gui.runtime", null, Locale.CHINA));
                        runtime.setBackground(null);
                        runtime.setEditable(false);
                    }
                    {
                        runtime_value = new JTextPane();
                        infoPanel.add(runtime_value);
                        runtime_value.setText("NULL");
                        runtime_value.setBackground(null);
                        runtime_value.setEditable(false);
                        runtime_value.setEnabled(false);
                    }
                }
            }
            {
                shortcut = new JPanel();
                inst.getContentPane().add(shortcut, BorderLayout.NORTH);
                shortcut.setSize(784, 35);
                shortcut.setPreferredSize(new Dimension(784, 35));
                shortcut.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                shortcut.setLayout(new BorderLayout());
                {
                    eventText = new JTextPane();
                    shortcut.add(eventText, BorderLayout.WEST);
                    eventText.setText(CONTEXT.getMessage("point.event.name", null, Locale.CHINA) + ": ");
                    eventText.setEditable(false);
                    eventText.setEnabled(true);
                    eventText.setBackground(null);
                    eventText.setCaretColor(new Color(0, 0, 0));
                }
                {
                    eventTextField = new JTextField();
                    shortcut.add(eventTextField, BorderLayout.CENTER);
                    eventTextField.setSize(500, 25);
                    eventTextField.setText("");
                    eventTextField.setPreferredSize(new Dimension(500, 25));
                    eventTextField.setEditable(false);
                }
                {
                    submit = new JButton();
                    shortcut.add(submit, BorderLayout.EAST);
                    submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
                    submit.setSize(new Dimension(75, 25));
                    submit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                submitActionPerformed(evt);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        }
    });

}

From source file:com.qawaa.gui.EventWebScanGUI.java

/**
* Auto-generated main method to display this JFrame
*//*from  w  w w  .j  a  v a 2s.c om*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            EventWebScanGUI inst = new EventWebScanGUI();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
            inst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            FlowLayout flowLayout = new FlowLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            flowLayout.setAlignOnBaseline(true);
            inst.setTitle(PROGRAM_NAME + " [" + PROGRAM_VERSION + "] " + " - " + DefaultMessage.SOFT_NAME
                    + " - " + DefaultMessage.COMPANY_NAME);
            {
                consoleScrollPane = new JScrollPane();
                inst.getContentPane().add(consoleScrollPane, BorderLayout.CENTER);
                {
                    consolePane = new JEditorPane();
                    consoleScrollPane.setViewportView(consolePane);
                    consolePane.setText("");
                    setConsoleRight();
                    jConsole = new JConsole(System.out, consolePane);
                    System.setOut(jConsole);
                    System.setErr(jConsole);
                    consolePane.setEditable(false);
                    consolePane.addMouseListener(new MouseAdapter() {
                        /* (non-Javadoc)
                         * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
                         */
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                consolePane.add(consoleRight);
                                consoleRight.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    });
                }
            }
            {
                infoPanel = new JPanel();
                inst.getContentPane().add(infoPanel, BorderLayout.SOUTH);
                infoPanel.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                infoPanel.setPreferredSize(new Dimension(784, 30));
                infoPanel.setLayout(flowLayout);
                {
                    {
                        statusbar_count = new JTextPane();
                        infoPanel.add(statusbar_count);
                        statusbar_count.setText(
                                CONTEXT.getMessage("event.web.scan.statusbar.count", null, Locale.CHINA));
                        statusbar_count.setBackground(null);
                        statusbar_count.setEditable(false);
                    }
                    {
                        statusbar_count_value = new JTextPane();
                        infoPanel.add(statusbar_count_value);
                        statusbar_count_value.setText(String.valueOf(SCAN_COUNT));
                        statusbar_count_value.setBackground(null);
                        statusbar_count_value.setEditable(false);
                        statusbar_count_value.setEnabled(false);
                    }
                    {
                        programPID = new JTextPane();
                        infoPanel.add(programPID);
                        programPID.setText("PID:");
                        programPID.setBackground(null);
                        programPID.setEditable(false);
                    }
                    {
                        programPID_value = new JTextPane();
                        infoPanel.add(programPID_value);
                        programPID_value.setText(JvmPid.getPID());
                        programPID_value.setBackground(null);
                        programPID_value.setEditable(false);
                        programPID_value.setEnabled(false);
                    }
                    {
                        memory = new JTextPane();
                        infoPanel.add(memory);
                        memory.setText(CONTEXT.getMessage("gobal.gui.memory", null, Locale.CHINA));
                        memory.setBackground(null);
                        memory.setEditable(false);
                    }
                    {
                        memory_value = new JTextPane();
                        infoPanel.add(memory_value);
                        memory_value.setText("0KB");
                        memory_value.setBackground(null);
                        memory_value.setEditable(false);
                        memory_value.setEnabled(false);
                        MemoryListener memory = new MemoryListener(memory_value);
                        memory.start();
                    }
                    {
                        runtime = new JTextPane();
                        infoPanel.add(runtime);
                        runtime.setText(CONTEXT.getMessage("gobal.gui.runtime", null, Locale.CHINA));
                        runtime.setBackground(null);
                        runtime.setEditable(false);
                    }
                    {
                        runtime_value = new JTextPane();
                        infoPanel.add(runtime_value);
                        runtime_value.setText("NULL");
                        runtime_value.setBackground(null);
                        runtime_value.setEditable(false);
                        runtime_value.setEnabled(false);
                    }
                }
            }
            {
                shortcut = new JPanel();
                inst.getContentPane().add(shortcut, BorderLayout.NORTH);
                shortcut.setSize(784, 35);
                shortcut.setPreferredSize(new Dimension(784, 35));
                shortcut.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                shortcut.setLayout(new BorderLayout());
                {
                    eventText = new JTextPane();
                    shortcut.add(eventText, BorderLayout.WEST);
                    eventText.setText(CONTEXT.getMessage("event.web.scan.name", null, Locale.CHINA) + ": ");
                    eventText.setEditable(false);
                    eventText.setEnabled(true);
                    eventText.setBackground(null);
                    eventText.setCaretColor(new Color(0, 0, 0));
                }
                {
                    eventTextField = new JTextField();
                    shortcut.add(eventTextField, BorderLayout.CENTER);
                    eventTextField.setSize(500, 25);
                    eventTextField.setText("");
                    eventTextField.setPreferredSize(new Dimension(500, 25));
                    eventTextField.setEditable(false);
                }
                {
                    submit = new JButton();
                    shortcut.add(submit, BorderLayout.EAST);
                    submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
                    submit.setSize(new Dimension(75, 25));
                    submit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                submitActionPerformed(evt);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        }
    });

}

From source file:Main.java

/**
 * Check to see if the event is for the left mouse button and the Alt key is pressed.
 * Also allows the right mouse button with the control key down. This is so it can
 * work via Citrix Receiver.//from   www . j a  va 2s  . c o m
 *
 * @param event
 * @return
 */
static boolean isLeftButtonAndAltDown(final MouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON1) {
        return isAltDown(event);
    } else if (event.getButton() == MouseEvent.BUTTON3) {
        return isControlDown(event);
    } else {
        return false;
    }
}

From source file:Main.java

public Main() {
    setLayout(null);// w  w  w. j ava 2 s.c o m
    add(button);
    button.setSize(button.getPreferredSize());
    button.setLocation(20, 20);
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            System.out.println(e.getButton() == MouseEvent.BUTTON3);
        }
    });
}

From source file:Main.java

public Main() {
    setSize(300, 300);//  w ww  .  j a v  a  2 s.c  o  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JTextArea textArea = new JTextArea();
    textArea.setText("Click Me!");

    textArea.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.NOBUTTON) {
                textArea.setText("No button clicked...");
            } else if (e.getButton() == MouseEvent.BUTTON1) {
                textArea.setText("Button 1 clicked...");
            } else if (e.getButton() == MouseEvent.BUTTON2) {
                textArea.setText("Button 2 clicked...");
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                textArea.setText("Button 3 clicked...");
            }

            System.out.println("Number of click: " + e.getClickCount());
            System.out.println("Click position (X, Y):  " + e.getX() + ", " + e.getY());
        }
    });

    getContentPane().add(textArea);
}

From source file:grafix.telas.componentes.GrafixChartMouseListener.java

public void chartMouseClicked(ChartMouseEvent evt) {
    if (evt.getTrigger().getButton() == MouseEvent.BUTTON3) {
        int clickY = evt.getTrigger().getY();
        for (int i = 0; i < panel.getNumPlots(); i++) {
            int finalPlot = (int) panel.getAreaData(i).getY() + (int) panel.getAreaData(i).getHeight();
            if (clickY <= finalPlot) {
                plotClicado = i;/*  w  w  w  .j a  v  a  2  s.  c o m*/
                popup.show(evt.getTrigger().getComponent(), evt.getTrigger().getX(), evt.getTrigger().getY());
                System.out.println("plot " + i);
                return;
            }
        }
    }
}

From source file:de.ailis.xadrian.utils.SwingUtils.java

/**
 * Gives a component a popup menu/*from w w  w.  j  av a  2 s .  c o  m*/
 * 
 * @param component
 *            The target component
 * @param popup
 *            The popup menu
 */
public static void setPopupMenu(final JComponent component, final JPopupMenu popup) {
    component.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            // Ignore mouse buttons outside of the normal range. This
            // fixes problems with trackpad scrolling.
            if (e.getButton() > MouseEvent.BUTTON3)
                return;

            if (e.isPopupTrigger()) {
                popup.show(component, e.getX(), e.getY());
            }
        }

        @Override
        public void mouseReleased(final MouseEvent e) {
            // Ignore mouse buttons outside of the normal range. This
            // fixes problems with trackpad scrolling.
            if (e.getButton() > MouseEvent.BUTTON3)
                return;

            if (e.isPopupTrigger()) {
                popup.show(component, e.getX(), e.getY());
            }
        }
    });
}

From source file:com.db2eshop.gui.component.tab.SaleTab.java

/**
 * <p>registerMouseListener.</p>
 *
 * @param jScrollPane a {@link javax.swing.JScrollPane} object.
 * @param table a {@link com.db2eshop.gui.component.table.api.GenericTable} object.
 *//*from  w w w.j av  a2  s.c  o m*/
public void registerMouseListener(JScrollPane jScrollPane, GenericTable<?> table) {
    jScrollPane.addMouseListener(new BaseMouseListener() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (arg0.getButton() == MouseEvent.BUTTON3) {
                tabRightClickPopupMenu.showMenu(arg0.getPoint(), null, null, saleTable);
            }
        }
    });
}

From source file:com.db2eshop.gui.component.tab.ImportTab.java

/**
 * <p>registerMouseListener.</p>
 *
 * @param jScrollPane a {@link javax.swing.JScrollPane} object.
 * @param table a {@link com.db2eshop.gui.component.table.api.GenericTable} object.
 *//*from   www.  j a v a2s .c o m*/
public void registerMouseListener(JScrollPane jScrollPane, GenericTable<?> table) {
    jScrollPane.addMouseListener(new BaseMouseListener() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (arg0.getButton() == MouseEvent.BUTTON3) {
                tabRightClickPopupMenu.showMenu(arg0.getPoint(), null, null, importTable);
            }
        }
    });
}

From source file:com.db2eshop.gui.component.tab.ArticleTab.java

/**
 * <p>registerMouseListener.</p>
 *
 * @param jScrollPane a {@link javax.swing.JScrollPane} object.
 * @param table a {@link com.db2eshop.gui.component.table.api.GenericTable} object.
 *///w w w  .j  a v a 2 s . co  m
public void registerMouseListener(JScrollPane jScrollPane, GenericTable<?> table) {
    jScrollPane.addMouseListener(new BaseMouseListener() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (arg0.getButton() == MouseEvent.BUTTON3) {
                tabRightClickPopupMenu.showMenu(arg0.getPoint(), null, null, articleTable);
            }
        }
    });
}