Search in sources :

Example 16 with MouseAdapter

use of java.awt.event.MouseAdapter in project antlrworks by antlr.

the class XJRollOverButton method init.

private void init() {
    setBorderPainted(false);
    setFocusable(false);
    setIconTextGap(0);
    setMargin(new Insets(0, 0, 0, 0));
    setContentAreaFilled(false);
    addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            inside = true;
            repaint();
        }

        @Override
        public void mouseExited(MouseEvent e) {
            inside = false;
            repaint();
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 17 with MouseAdapter

use of java.awt.event.MouseAdapter in project jna by java-native-access.

the class BalloonManagerDemo method main.

public static void main(String[] args) {
    try {
        System.setProperty("sun.java2d.noddraw", "true");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
    JFrame f = new JFrame("Balloon Test");
    final String BALLOON_TEXT = "<html><center>" + "This is some sample balloon text<br>" + "which has been formatted with html.<br>" + "Click to dismiss.</center></html>";
    final JLabel content = new JLabel(BALLOON_TEXT);
    content.setIconTextGap(10);
    content.setBorder(new EmptyBorder(0, 8, 0, 8));
    content.setSize(content.getPreferredSize());
    content.setIcon(new InfoIcon());
    JLabel label = new JLabel("Click anywhere for more information");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.addMouseListener(new MouseAdapter() {

        private MouseListener listener = new MouseAdapter() {

            public void mousePressed(MouseEvent e) {
                hidePopup(e);
            }
        };

        private Popup popup;

        private void hidePopup(MouseEvent e) {
            e.getComponent().removeMouseListener(listener);
            if (popup != null)
                popup.hide();
        }

        public void mousePressed(MouseEvent e) {
            hidePopup(e);
            popup = BalloonManager.getBalloon(e.getComponent(), content, e.getX(), e.getY());
            popup.show();
            content.getParent().addMouseListener(listener);
        }
    });
    f.getContentPane().add(label);
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.setLocation(100, 100);
    try {
        // Force a load of JNA
        WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } catch (UnsatisfiedLinkError e) {
        e.printStackTrace();
        String msg = e.getMessage() + "\nError loading the JNA library";
        JTextArea area = new JTextArea(msg);
        area.setOpaque(false);
        area.setFont(UIManager.getFont("Label.font"));
        area.setEditable(false);
        area.setColumns(80);
        area.setRows(8);
        area.setWrapStyleWord(true);
        area.setLineWrap(true);
        JOptionPane.showMessageDialog(null, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) JTextArea(javax.swing.JTextArea) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) MouseListener(java.awt.event.MouseListener) JFrame(javax.swing.JFrame) Popup(javax.swing.Popup) EmptyBorder(javax.swing.border.EmptyBorder)

Example 18 with MouseAdapter

use of java.awt.event.MouseAdapter in project groovy by apache.

the class TableSorter method addMouseListenerToHeaderInTable.

// There is no-where else to put this.
// Add a mouse listener to the Table to trigger a table sort
// when a column heading is clicked in the JTable.
public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    MouseAdapter listMouseListener = new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = tableView.convertColumnIndexToModel(viewColumn);
            if (e.getClickCount() == 1 && column != -1) {
                if (lastSortedColumn == column)
                    ascending = !ascending;
                sorter.sortByColumn(column, ascending);
                lastSortedColumn = column;
            }
        }
    };
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) TableColumnModel(javax.swing.table.TableColumnModel) JTableHeader(javax.swing.table.JTableHeader)

Example 19 with MouseAdapter

use of java.awt.event.MouseAdapter in project neo4j by neo4j.

the class MainWindow method createStatusPanel.

private JPanel createStatusPanel(CardLayout statusPanelLayout) {
    JPanel panel = withLayout(statusPanelLayout, withTitledBorder("Status", createPanel()));
    for (DatabaseStatus status : DatabaseStatus.values()) {
        panel.add(status.name(), status.display(model));
    }
    panel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (MouseEvent.BUTTON1 == e.getButton() && e.isAltDown()) {
                debugWindow.show();
            }
        }
    });
    return panel;
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 20 with MouseAdapter

use of java.awt.event.MouseAdapter in project neo4j by neo4j.

the class SysTray method setupTrayIcon.

private void setupTrayIcon() {
    PopupMenu popUpMenu = createPopupMenu();
    trayIcon.setPopupMenu(popUpMenu);
    trayIcon.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            listener.open();
        }
    });
    trayIcon.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            listener.open();
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter)

Aggregations

MouseAdapter (java.awt.event.MouseAdapter)202 MouseEvent (java.awt.event.MouseEvent)199 JLabel (javax.swing.JLabel)52 JPanel (javax.swing.JPanel)48 ActionEvent (java.awt.event.ActionEvent)36 JScrollPane (javax.swing.JScrollPane)36 BorderLayout (java.awt.BorderLayout)35 Dimension (java.awt.Dimension)34 JButton (javax.swing.JButton)33 ActionListener (java.awt.event.ActionListener)32 Insets (java.awt.Insets)24 GridBagConstraints (java.awt.GridBagConstraints)20 KeyEvent (java.awt.event.KeyEvent)20 KeyAdapter (java.awt.event.KeyAdapter)19 JTextField (javax.swing.JTextField)16 ListSelectionEvent (javax.swing.event.ListSelectionEvent)16 Component (java.awt.Component)15 Point (java.awt.Point)15 JTable (javax.swing.JTable)15 ListSelectionListener (javax.swing.event.ListSelectionListener)15