Search in sources :

Example 61 with MouseAdapter

use of java.awt.event.MouseAdapter in project jadx by skylot.

the class TextStandardActions method registerListeners.

private void registerListeners() {
    textComponent.addMouseListener(new MouseAdapter() {

        public void mouseReleased(MouseEvent e) {
            if (e.getModifiers() == InputEvent.BUTTON3_MASK && e.getSource() == textComponent) {
                process(e);
            }
        }
    });
    textComponent.getDocument().addUndoableEditListener(new UndoableEditListener() {

        public void undoableEditHappened(UndoableEditEvent event) {
            undoManager.addEdit(event.getEdit());
        }
    });
}
Also used : UndoableEditListener(javax.swing.event.UndoableEditListener) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) UndoableEditEvent(javax.swing.event.UndoableEditEvent)

Example 62 with MouseAdapter

use of java.awt.event.MouseAdapter in project dbeaver by serge-rider.

the class TrayIconHandler method show.

public void show() {
    if (trayItem != null) {
        return;
    }
    File logoFile;
    try {
        logoFile = RuntimeUtils.getPlatformFile(UIIcon.DBEAVER_LOGO.getLocation());
    } catch (IOException e) {
        log.error(e);
        return;
    }
    trayItem = new TrayIcon(Toolkit.getDefaultToolkit().getImage(logoFile.getAbsolutePath()));
    trayItem.setImageAutoSize(true);
    trayItem.addActionListener(new ActionListener() {

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

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });
    // Add tooltip and menu to tray icon
    trayItem.setToolTip(GeneralUtils.getProductTitle());
    // area
    try {
        SystemTray.getSystemTray().add(trayItem);
    } catch (AWTException e) {
        log.error(e);
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) IOException(java.io.IOException) File(java.io.File)

Example 63 with MouseAdapter

use of java.awt.event.MouseAdapter in project jgnash by ccavanaugh.

the class RecurringPanel method initComponents.

private void initComponents() {
    JPanel toolPanel = new JPanel(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    newButton = new RollOverButton(rb.getString("Button.New"), IconUtils.getIcon("/jgnash/resource/document-new.png"));
    modifyButton = new RollOverButton(rb.getString("Button.Modify"), IconUtils.getIcon("/jgnash/resource/document-properties.png"));
    deleteButton = new RollOverButton(rb.getString("Button.Delete"), IconUtils.getIcon("/jgnash/resource/edit-delete.png"));
    remindersButton = new RollOverButton(rb.getString("Button.CheckReminders"), IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
    reminderTable = new FormattedJTable();
    reminderTable.setAutoCreateRowSorter(true);
    reminderTable.setFillsViewportHeight(true);
    reminderTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    reminderTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(final KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteReminder();
            }
        }
    });
    reminderTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                showModifyDialog();
            }
        }
    });
    setLayout(new BorderLayout());
    toolBar.add(newButton);
    toolBar.add(modifyButton);
    toolBar.add(deleteButton);
    toolBar.addSeparator();
    toolBar.add(remindersButton);
    toolPanel.add(toolBar, BorderLayout.NORTH);
    toolPanel.add(new JSeparator(), BorderLayout.CENTER);
    add(toolPanel, java.awt.BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setAutoscrolls(true);
    scrollPane.setViewportView(reminderTable);
    add(scrollPane, java.awt.BorderLayout.CENTER);
    deleteButton.addActionListener(this);
    modifyButton.addActionListener(this);
    newButton.addActionListener(this);
    remindersButton.addActionListener(this);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) RollOverButton(jgnash.ui.components.RollOverButton) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) JToolBar(javax.swing.JToolBar) JSeparator(javax.swing.JSeparator) FormattedJTable(jgnash.ui.components.FormattedJTable) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) EmptyBorder(javax.swing.border.EmptyBorder)

Example 64 with MouseAdapter

use of java.awt.event.MouseAdapter in project jdk8u_jdk by JetBrains.

the class MotifFileChooserUI method createFilesList.

protected JScrollPane createFilesList() {
    fileList = new JList<File>();
    if (getFileChooser().isMultiSelectionEnabled()) {
        fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else {
        fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    fileList.setModel(new MotifFileListModel());
    fileList.getSelectionModel().removeSelectionInterval(0, 0);
    fileList.setCellRenderer(new FileCellRenderer());
    fileList.addListSelectionListener(createListSelectionListener(getFileChooser()));
    fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList));
    fileList.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            JFileChooser chooser = getFileChooser();
            if (SwingUtilities.isLeftMouseButton(e) && !chooser.isMultiSelectionEnabled()) {
                int index = SwingUtilities2.loc2IndexFileList(fileList, e.getPoint());
                if (index >= 0) {
                    File file = fileList.getModel().getElementAt(index);
                    setFileName(chooser.getName(file));
                }
            }
        }
    });
    align(fileList);
    JScrollPane scrollpane = new JScrollPane(fileList);
    scrollpane.setPreferredSize(prefListSize);
    scrollpane.setMaximumSize(MAX_SIZE);
    align(scrollpane);
    fileList.setInheritsPopupMenu(true);
    scrollpane.setInheritsPopupMenu(true);
    return scrollpane;
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) File(java.io.File)

Example 65 with MouseAdapter

use of java.awt.event.MouseAdapter in project jabref by JabRef.

the class EntryEditor method setupToolBar.

private void setupToolBar() {
    JPanel leftPan = new JPanel();
    leftPan.setLayout(new BorderLayout());
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setBorder(null);
    toolBar.setRollover(true);
    toolBar.setMargin(new Insets(0, 0, 0, 2));
    // The toolbar carries all the key bindings that are valid for the whole window.
    ActionMap actionMap = toolBar.getActionMap();
    InputMap inputMap = toolBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_ENTRY_EDITOR), "close");
    actionMap.put("close", closeAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store");
    actionMap.put("store", storeFieldAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOGENERATE_BIBTEX_KEYS), "generateKey");
    actionMap.put("generateKey", generateKeyAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOMATICALLY_LINK_FILES), "autoLink");
    actionMap.put("autoLink", autoLinkAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_ENTRY), "prev");
    actionMap.put("prev", prevEntryAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_ENTRY), "next");
    actionMap.put("next", nextEntryAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo");
    actionMap.put("undo", undoAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo");
    actionMap.put("redo", redoAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help");
    actionMap.put("help", helpAction);
    toolBar.setFloatable(false);
    // Add actions (and thus buttons)
    JButton closeBut = new JButton(closeAction);
    closeBut.setText(null);
    closeBut.setBorder(null);
    closeBut.setMargin(new Insets(8, 0, 8, 0));
    leftPan.add(closeBut, BorderLayout.NORTH);
    // Create type-label
    TypedBibEntry typedEntry = new TypedBibEntry(entry, panel.getBibDatabaseContext().getMode());
    leftPan.add(new TypeLabel(typedEntry.getTypeForDisplay()), BorderLayout.CENTER);
    TypeButton typeButton = new TypeButton();
    toolBar.add(typeButton);
    toolBar.add(generateKeyAction);
    toolBar.add(autoLinkAction);
    toolBar.add(writeXmp);
    JPopupMenu fetcherPopup = new JPopupMenu();
    for (EntryBasedFetcher fetcher : WebFetchers.getEntryBasedFetchers(Globals.prefs.getImportFormatPreferences())) {
        fetcherPopup.add(new JMenuItem(new AbstractAction(fetcher.getName()) {

            @Override
            public void actionPerformed(ActionEvent e) {
                new EntryFetchAndMergeWorker(panel, getEntry(), fetcher).execute();
            }
        }));
    }
    JButton fetcherButton = new JButton(IconTheme.JabRefIcon.REFRESH.getIcon());
    fetcherButton.setToolTipText(Localization.lang("Update with bibliographic information from the web"));
    fetcherButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            fetcherPopup.show(e.getComponent(), e.getX(), e.getY());
        }
    });
    toolBar.add(fetcherButton);
    toolBar.addSeparator();
    toolBar.add(deleteAction);
    toolBar.add(prevEntryAction);
    toolBar.add(nextEntryAction);
    toolBar.addSeparator();
    toolBar.add(helpAction);
    Component[] comps = toolBar.getComponents();
    for (Component comp : comps) {
        ((JComponent) comp).setOpaque(false);
    }
    leftPan.add(toolBar, BorderLayout.SOUTH);
    add(leftPan, BorderLayout.WEST);
}
Also used : JPanel(javax.swing.JPanel) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JComponent(javax.swing.JComponent) EntryFetchAndMergeWorker(org.jabref.gui.mergeentries.EntryFetchAndMergeWorker) JToolBar(javax.swing.JToolBar) TypedBibEntry(org.jabref.logic.TypedBibEntry) JPopupMenu(javax.swing.JPopupMenu) BorderLayout(java.awt.BorderLayout) OSXCompatibleToolbar(org.jabref.gui.OSXCompatibleToolbar) InputMap(javax.swing.InputMap) EntryBasedFetcher(org.jabref.logic.importer.EntryBasedFetcher) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) AbstractAction(javax.swing.AbstractAction)

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