Search in sources :

Example 76 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project keystore-explorer by kaikramer.

the class DAddExtensions method initComponents.

private void initComponents() {
    jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbAdd.image")))));
    jbAdd.setMargin(new Insets(2, 2, 0, 0));
    jbAdd.setToolTipText(res.getString("DAddExtensions.jbAdd.tooltip"));
    jbAdd.setMnemonic(res.getString("DAddExtensions.jbAdd.mnemonic").charAt(0));
    jbAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                addPressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbEdit.image")))));
    jbEdit.setMargin(new Insets(2, 2, 0, 0));
    jbEdit.setToolTipText(res.getString("DAddExtensions.jbEdit.tooltip"));
    jbEdit.setMnemonic(res.getString("DAddExtensions.jbEdit.mnemonic").charAt(0));
    jbEdit.setEnabled(false);
    jbEdit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                editPressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbToggleCriticality = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbToggleCriticality.image")))));
    jbToggleCriticality.setMargin(new Insets(2, 2, 0, 0));
    jbToggleCriticality.setToolTipText(res.getString("DAddExtensions.jbToggleCriticality.tooltip"));
    jbToggleCriticality.setMnemonic(res.getString("DAddExtensions.jbToggleCriticality.mnemonic").charAt(0));
    jbToggleCriticality.setEnabled(false);
    jbToggleCriticality.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                toggleCriticalityPressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbRemove.image")))));
    jbRemove.setMargin(new Insets(2, 2, 0, 0));
    jbRemove.setToolTipText(res.getString("DAddExtensions.jbRemove.tooltip"));
    jbRemove.setMnemonic(res.getString("DAddExtensions.jbRemove.mnemonic").charAt(0));
    jbRemove.setEnabled(false);
    jbRemove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                removePressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jpExtensionButtons = new JPanel();
    jpExtensionButtons.setLayout(new BoxLayout(jpExtensionButtons, BoxLayout.Y_AXIS));
    jpExtensionButtons.add(Box.createVerticalGlue());
    jpExtensionButtons.add(jbAdd);
    jpExtensionButtons.add(Box.createVerticalStrut(3));
    jpExtensionButtons.add(jbEdit);
    jpExtensionButtons.add(Box.createVerticalStrut(3));
    jpExtensionButtons.add(jbToggleCriticality);
    jpExtensionButtons.add(Box.createVerticalStrut(3));
    jpExtensionButtons.add(jbRemove);
    jpExtensionButtons.add(Box.createVerticalGlue());
    ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel();
    jtExtensions = new JKseTable(extensionsTableModel);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel);
    sorter.setComparator(2, new ObjectIdComparator());
    jtExtensions.setRowSorter(sorter);
    jtExtensions.setShowGrid(false);
    jtExtensions.setRowMargin(0);
    jtExtensions.getColumnModel().setColumnMargin(0);
    jtExtensions.getTableHeader().setReorderingAllowed(false);
    jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight()));
    for (int i = 0; i < jtExtensions.getColumnCount(); i++) {
        TableColumn column = jtExtensions.getColumnModel().getColumn(i);
        column.setHeaderRenderer(new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new ExtensionsTableCellRend());
    }
    TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0);
    criticalCol.setResizable(false);
    criticalCol.setMinWidth(28);
    criticalCol.setMaxWidth(28);
    criticalCol.setPreferredWidth(28);
    ListSelectionModel selectionModel = jtExtensions.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                try {
                    CursorUtil.setCursorBusy(DAddExtensions.this);
                    updateButtonControls();
                } finally {
                    CursorUtil.setCursorFree(DAddExtensions.this);
                }
            }
        }
    });
    jtExtensions.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            maybeEditExtension(evt);
        }
    });
    jtExtensions.addKeyListener(new KeyAdapter() {

        boolean deleteLastPressed = false;

        @Override
        public void keyPressed(KeyEvent evt) {
            // Record delete pressed on non-Macs
            if (!OperatingSystem.isMacOs()) {
                deleteLastPressed = evt.getKeyCode() == KeyEvent.VK_DELETE;
            }
        }

        @Override
        public void keyReleased(KeyEvent evt) {
            // Delete on non-Mac if delete was pressed and is now released
            if (!OperatingSystem.isMacOs() && deleteLastPressed && evt.getKeyCode() == KeyEvent.VK_DELETE) {
                try {
                    CursorUtil.setCursorBusy(DAddExtensions.this);
                    deleteLastPressed = false;
                    removeSelectedExtension();
                } finally {
                    CursorUtil.setCursorFree(DAddExtensions.this);
                }
            }
        }

        @Override
        public void keyTyped(KeyEvent evt) {
            // Delete on Mac if back space typed
            if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
                try {
                    CursorUtil.setCursorBusy(DAddExtensions.this);
                    removeSelectedExtension();
                } finally {
                    CursorUtil.setCursorFree(DAddExtensions.this);
                }
            }
        }
    });
    jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground());
    jbLoadTemplate = new JButton(res.getString("DAddExtensions.jbLoadTemplate.text"));
    jbLoadTemplate.setMnemonic(res.getString("DAddExtensions.jbLoadTemplate.mnemonic").charAt(0));
    jbLoadTemplate.setToolTipText(res.getString("DAddExtensions.jbLoadTemplate.tooltip"));
    jbLoadTemplate.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                loadTemplatePressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbSaveTemplate = new JButton(res.getString("DAddExtensions.jbSaveTemplate.text"));
    jbSaveTemplate.setMnemonic(res.getString("DAddExtensions.jbSaveTemplate.mnemonic").charAt(0));
    jbSaveTemplate.setToolTipText(res.getString("DAddExtensions.jbSaveTemplate.tooltip"));
    jbSaveTemplate.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                saveTemplatePressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jpLoadSaveTemplate = new JPanel();
    jpLoadSaveTemplate.setLayout(new BoxLayout(jpLoadSaveTemplate, BoxLayout.X_AXIS));
    jpLoadSaveTemplate.add(Box.createHorizontalGlue());
    jpLoadSaveTemplate.add(jbLoadTemplate);
    jpLoadSaveTemplate.add(Box.createHorizontalStrut(5));
    jpLoadSaveTemplate.add(jbSaveTemplate);
    jpExtensions = new JPanel(new BorderLayout(5, 5));
    jpExtensions.setPreferredSize(new Dimension(450, 200));
    jpExtensions.add(jspExtensionsTable, BorderLayout.CENTER);
    jpExtensions.add(jpExtensionButtons, BorderLayout.EAST);
    jpExtensions.add(jpLoadSaveTemplate, BorderLayout.SOUTH);
    jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
    jbOK = new JButton(res.getString("DAddExtensions.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jbCancel = new JButton(res.getString("DAddExtensions.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
    reloadExtensionsTable();
    selectFirstExtensionInTable();
    updateButtonControls();
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpExtensions, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) WindowAdapter(java.awt.event.WindowAdapter) ObjectIdComparator(org.kse.utilities.oid.ObjectIdComparator) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction) TableRowSorter(javax.swing.table.TableRowSorter) MouseEvent(java.awt.event.MouseEvent) JKseTable(org.kse.gui.JKseTable) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) TableModel(javax.swing.table.TableModel)

Example 77 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project pmd by pmd.

the class EvaluationResultsPanel method init.

private void init() {
    model.addViewerModelListener(this);
    list = new JList();
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (list.getSelectedValue() != null) {
                model.selectNode((Node) list.getSelectedValue(), EvaluationResultsPanel.this);
            }
        }
    });
    add(new JScrollPane(list), BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) Node(net.sourceforge.pmd.lang.ast.Node) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JList(javax.swing.JList) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 78 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project jbpm by kiegroup.

the class ChecklistUI method initializeComponent.

private void initializeComponent() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    getRootPane().setLayout(new BorderLayout());
    getRootPane().add(panel, BorderLayout.CENTER);
    JButton createButton = new JButton("New...");
    createButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            create();
        }
    });
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.WEST;
    panel.add(createButton, c);
    contexts = new JComboBox(new DefaultComboBoxModel());
    contexts.setPreferredSize(new Dimension(80, 24));
    contexts.setSize(new Dimension(80, 24));
    c = new GridBagConstraints();
    c.weightx = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(contexts, c);
    contexts.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            refresh();
        }
    });
    JButton refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            refresh();
        }
    });
    c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(refreshButton, c);
    itemTable = new JTable(1, 6);
    itemTable.setRowHeight(35);
    itemTable.setShowHorizontalLines(false);
    itemTable.setShowVerticalLines(false);
    itemTable.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
            ctrl = false;
        }

        public void keyPressed(KeyEvent e) {
            if (e.isControlDown()) {
                ctrl = true;
            }
        }
    });
    itemTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            int index = e.getFirstIndex();
            if (index >= 0 && index < items.size()) {
                ChecklistItem item = items.get(index);
                if (item.getStatus() == Status.Created) {
                    String actorId = getActorId();
                    try {
                        checklistManager.claimTask(actorId, item.getTaskId());
                        if (ctrl) {
                            checklistManager.abortTask(actorId, item.getTaskId());
                        } else {
                            checklistManager.completeTask(actorId, item.getTaskId());
                        }
                    } catch (Throwable t) {
                    // Do nothing
                    }
                    refresh();
                } else if (item.getStatus() == Status.Reserved) {
                    String actorId = getActorId();
                    if (item.getActors().equals(actorId)) {
                        try {
                            if (ctrl) {
                                checklistManager.abortTask(actorId, item.getTaskId());
                            } else {
                                checklistManager.completeTask(actorId, item.getTaskId());
                            }
                        } catch (Throwable t) {
                        // Do nothing
                        }
                        refresh();
                    }
                } else if (item.getStatus() == Status.Optional) {
                    try {
                        checklistManager.selectOptionalTask(item.getName(), Long.valueOf((String) contexts.getSelectedItem()));
                    } catch (Throwable t) {
                        // Do nothing
                        t.printStackTrace();
                    }
                    refresh();
                }
            }
        }
    });
    // TODO:
    // default width of columns
    // icons for state
    // not-editable
    // no selection
    // (scratch for aborted?)
    // replace refresh, create, etc. by icon
    c = new GridBagConstraints();
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(itemTable, c);
    JLabel nameLabel = new JLabel("Logged in as:");
    c = new GridBagConstraints();
    c.gridy = 2;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.WEST;
    panel.add(nameLabel, c);
    userNameTextField = new JTextField("krisv");
    userNameTextField.setPreferredSize(new Dimension(80, 20));
    userNameTextField.setSize(new Dimension(80, 20));
    c = new GridBagConstraints();
    c.gridy = 2;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.WEST;
    panel.add(userNameTextField, c);
    JButton createItemButton = new JButton("+");
    createItemButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            createNewItem();
        }
    });
    c = new GridBagConstraints();
    c.gridy = 2;
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.EAST;
    panel.add(createItemButton, c);
    panel.doLayout();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) ListSelectionListener(javax.swing.event.ListSelectionListener) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) ChecklistItem(org.jbpm.examples.checklist.ChecklistItem) KeyListener(java.awt.event.KeyListener)

Example 79 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project jbpm by kiegroup.

the class HumanTaskHandler method initializeComponent.

private void initializeComponent() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    getRootPane().setLayout(new BorderLayout());
    getRootPane().add(panel, BorderLayout.CENTER);
    JLabel label = new JLabel("Actor");
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(label, c);
    actorTextField = new JTextField();
    c = new GridBagConstraints();
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(actorTextField, c);
    JButton updateButton = new JButton("Update");
    updateButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            update();
        }
    });
    c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(updateButton, c);
    workItemsList = new JList();
    workItemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    workItemsList.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                select();
            }
        }
    });
    workItemsList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            selectButton.setEnabled(getSelectedWorkItem() != null);
        }
    });
    c = new GridBagConstraints();
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(workItemsList, c);
    selectButton = new JButton("Select");
    selectButton.setEnabled(false);
    selectButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            select();
        }
    });
    c = new GridBagConstraints();
    c.gridy = 2;
    c.weightx = 1;
    c.gridwidth = 3;
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(selectButton, c);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JList(javax.swing.JList)

Example 80 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project chatty by chatty.

the class FavoritesDialog method setupTable.

private void setupTable() {
    table.setShowGrid(false);
    table.setDefaultRenderer(Boolean.class, new FavoriteRenderer());
    table.setDefaultRenderer(Long.class, new TimeRenderer());
    table.getTableHeader().addMouseListener(sorter);
    table.getTableHeader().setReorderingAllowed(false);
    table.getTableHeader().setDefaultRenderer(new MyDefaultTableHeaderCellRenderer());
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            selectionChanged();
        }
    });
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                doneButton.doClick();
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            openContextMenu(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            openContextMenu(e);
        }
    });
    // Shortcuts
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_J, 0), "done");
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "done");
    table.getActionMap().put("done", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            doneButton.doClick();
        }
    });
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");
    table.getActionMap().put("delete", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            remove();
        }
    });
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F, 0), "addFav");
    table.getActionMap().put("addFav", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addToFavoritesButton.doClick();
        }
    });
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_U, 0), "unFav");
    table.getActionMap().put("unFav", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeFromFavoritesButton.doClick();
        }
    });
    // Column Sizes
    TableColumn favColumn = table.getColumnModel().getColumn(COLUMN_FAV);
    favColumn.setMaxWidth(FAV_COLUMN_WIDTH);
    favColumn.setMinWidth(FAV_COLUMN_WIDTH);
    TableColumn timeColumn = table.getColumnModel().getColumn(COLUMN_AGO);
    timeColumn.setMaxWidth(TIME_COLUMN_WIDTH);
    timeColumn.setMinWidth(TIME_COLUMN_WIDTH);
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) TableColumn(javax.swing.table.TableColumn) ListSelectionListener(javax.swing.event.ListSelectionListener)

Aggregations

ListSelectionListener (javax.swing.event.ListSelectionListener)216 ListSelectionEvent (javax.swing.event.ListSelectionEvent)210 ActionEvent (java.awt.event.ActionEvent)90 ActionListener (java.awt.event.ActionListener)76 JScrollPane (javax.swing.JScrollPane)72 JPanel (javax.swing.JPanel)67 JButton (javax.swing.JButton)61 BorderLayout (java.awt.BorderLayout)53 MouseEvent (java.awt.event.MouseEvent)47 Dimension (java.awt.Dimension)44 JLabel (javax.swing.JLabel)40 MouseAdapter (java.awt.event.MouseAdapter)37 JTable (javax.swing.JTable)36 FlowLayout (java.awt.FlowLayout)28 Insets (java.awt.Insets)28 JList (javax.swing.JList)27 List (java.util.List)24 ArrayList (java.util.ArrayList)22 KeyEvent (java.awt.event.KeyEvent)21 GridBagConstraints (java.awt.GridBagConstraints)20