Example usage for javax.swing JToolBar JToolBar

List of usage examples for javax.swing JToolBar JToolBar

Introduction

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

Prototype

public JToolBar() 

Source Link

Document

Creates a new tool bar; orientation defaults to HORIZONTAL.

Usage

From source file:savant.snp.SNPFinderPlugin.java

private void setupGUI(JPanel panel) {

    // add a toolbar
    JToolBar tb = new JToolBar();
    tb.setName("SNP Finder Toolbar");

    // add an ON/OFF checkbox
    JLabel lab_on = new JLabel("On/Off: ");
    JCheckBox cb_on = new JCheckBox();
    cb_on.setSelected(isSNPFinderOn);/*from  ww  w .ja  va 2 s  . c o m*/

    // what to do when a user clicks the checkbox
    cb_on.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // switch the SNP finder on/off
            setIsOn(!isSNPFinderOn);
            addMessage("Turning SNP finder " + (isSNPFinderOn ? "on" : "off"));
        }
    });
    // add a  Bookmarking ON/OFF checkbox
    JLabel lab_bm = new JLabel("Add Bookmarks: ");
    JCheckBox cb_bm = new JCheckBox();
    cb_bm.setSelected(addBookmarks);

    // what to do when a user clicks the checkbox
    cb_bm.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // switch the SNP finder on/off
            setBookmarking(!addBookmarks);
            addMessage("Turning Bookmarking " + (addBookmarks ? "on" : "off"));
        }
    });

    JLabel lab_sp = new JLabel("Heterozygosity: ");
    //add snp prior textfield
    final JTextField snpPriorField = new JTextField(String.valueOf(snpPrior), 4);
    snpPriorField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                setSNPPrior(Double.valueOf(snpPriorField.getText()));
            } catch (NumberFormatException ex) {
                snpPriorField.setText(String.valueOf(snpPrior));
            }
        }
    });
    int tfwidth = 35;
    int tfheight = 22;
    snpPriorField.setPreferredSize(new Dimension(tfwidth, tfheight));
    snpPriorField.setMaximumSize(new Dimension(tfwidth, tfheight));
    snpPriorField.setMinimumSize(new Dimension(tfwidth, tfheight));

    // add a sensitivity slider
    JLabel lab_confidence = new JLabel("Confidence: ");
    final JSlider sens_slider = new JSlider(0, 50);
    sens_slider.setValue(confidence);
    final JLabel lab_confidence_status = new JLabel("" + sens_slider.getValue());

    // what to do when a user slides the slider
    sens_slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            // set the snp finder's sensitivity
            lab_confidence_status.setText("" + sens_slider.getValue());
            setSensitivity(sens_slider.getValue());
        }
    });
    // don't report the new setting until the user stops sliding
    sens_slider.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            addMessage("Changed confidence to " + confidence);
        }
    });

    // add a transparency slider
    JLabel lab_trans = new JLabel("Transparency: ");
    final JSlider trans_slider = new JSlider(0, 100);
    trans_slider.setValue(transparency);
    final JLabel lab_transparency_status = new JLabel("" + trans_slider.getValue());

    // what to do when a user slides the slider
    trans_slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            // set the snp finder's transparency
            lab_transparency_status.setText("" + trans_slider.getValue());
            setTransparency(trans_slider.getValue());
        }
    });

    // don't report the new setting until the user stops sliding
    trans_slider.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            addMessage("Changed transparency to " + transparency);
        }
    });

    // add the components to the GUI
    panel.setLayout(new BorderLayout());
    tb.add(lab_on);
    tb.add(cb_on);
    tb.add(lab_bm);
    tb.add(cb_bm);
    tb.add(new JToolBar.Separator());
    tb.add(lab_sp);
    tb.add(snpPriorField);
    tb.add(new JToolBar.Separator());
    tb.add(lab_confidence);
    tb.add(sens_slider);
    tb.add(lab_confidence_status);

    tb.add(new JToolBar.Separator());

    tb.add(lab_trans);
    tb.add(trans_slider);
    tb.add(lab_transparency_status);

    panel.add(tb, BorderLayout.NORTH);

    // add a text area to the GUI
    info = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(info);
    panel.add(scrollPane, BorderLayout.CENTER);

}

From source file:savant.view.variation.swing.VariationModule.java

public VariationModule(VariationController vc) {
    super(new GridBagLayout());
    controller = vc;/*w w  w . ja va 2s . co m*/

    // Toolbar shared by all panels.
    JToolBar tools = new JToolBar();
    tools.setFloatable(false);
    rangeField = new JTextField();
    rangeField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            String text = rangeField.getText();
            try {
                Bookmark bm = new Bookmark(text, controller.getReference(), controller.getVisibleRange());
                controller.setLocation(bm.getReference(), (Range) bm.getRange());
            } catch (ParseException x) {
                DialogUtils.displayMessage(String.format("Unable to parse \"%s\" as a location.", text));
            }
        }
    });
    tools.add(rangeField);
    tools.addSeparator();

    JButton zoomInButton = new JButton();
    zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN));
    zoomInButton.setBorderPainted(false);
    zoomInButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            controller.zoomIn();
        }
    });
    tools.add(zoomInButton);

    JButton zoomOutButton = new JButton();
    zoomOutButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT));
    zoomOutButton.setBorderPainted(false);
    zoomOutButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            controller.zoomOut();
        }
    });
    tools.add(zoomOutButton);

    tools.addSeparator();
    JButton controlsButton = new JButton("Controls");
    controlsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (controller.getTracks().length > 0) {
                new CaseControlDialog(controller).setVisible(true);
                frequencyPlot.repaint();
            } else {
                Toolkit.getDefaultToolkit().beep();
            }
        }
    });
    tools.add(controlsButton);

    tabs = new JTabbedPane();
    table = new RecordTable(new VariantTableModel(null));
    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            if (me.getClickCount() == 2) {
                controller.navigateToRecord(controller.getData().get(table.getSelectedRow()));
            }
        }
    });
    tabs.addTab("Table", new JScrollPane(table));

    map = new VariantMap(controller);
    map.addMouseWheelListener(wheelListener);
    LocationController.getInstance().addListener(new Listener<LocationChangedEvent>() {
        @Override
        public void handleEvent(LocationChangedEvent event) {
            map.repaint();
        }
    });
    JPanel mapPanel = populatePanel(map);
    tabs.addTab("Map", mapPanel);

    frequencyPlot = new AlleleFrequencyPlot(controller);
    frequencyPlot.addMouseWheelListener(wheelListener);
    JPanel frequencyPanel = populatePanel(frequencyPlot);
    tabs.addTab("Allele Frequency", frequencyPanel);

    JPanel ldPanel = new JPanel();
    ldPanel.setLayout(new GridBagLayout());

    ActionListener redrawForcer = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ldPlot.repaint();
        }
    };
    JRadioButton dPrimeButton = new JRadioButton("D\u2032", true);
    dPrimeButton.setActionCommand("true");
    dPrimeButton.addActionListener(redrawForcer);
    JRadioButton rSquaredButton = new JRadioButton("r\u00B2", false);
    rSquaredButton.setActionCommand("false");
    rSquaredButton.addActionListener(redrawForcer);

    methodGroup = new ButtonGroup();
    JPanel methodPanel = new JPanel();
    methodPanel.setBorder(BorderFactory.createTitledBorder("Calculation Method"));
    methodPanel.add(dPrimeButton);
    methodGroup.add(dPrimeButton);
    methodPanel.add(rSquaredButton);
    methodGroup.add(rSquaredButton);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    ldPanel.add(methodPanel, gbc);

    ldPlot = new LDPlot(controller);
    JPanel lowerLDPanel = populatePanel(ldPlot);
    gbc.weighty = 1.0;
    ldPanel.add(lowerLDPanel, gbc);

    tabs.addTab("LD Plot", ldPanel);

    gbc.weighty = 0.0;
    add(tools, gbc);

    // Create the informative cards, but don't use them.
    messageLabel = new JLabel();
    messageLabel.setFont(MESSAGE_FONT);
    messagePanel = populatePanel(messageLabel);

    progressPanel = new ProgressPanel(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            controller.cancelDataRequests();
        }
    });

    showCard(tabs, null);
}

From source file:simplesqlformatter.formatter.SQLFormatterEditor.java

/**
 * Creates a new instance of a Simple SQL Formatter editor main
 * window.//from   w  ww .j a va2s .c o m
 * 
 * @param debug
 *        Whether to show the debug window
 */
public SQLFormatterEditor(final boolean debug) {

    setTitle("Simple SQL Formatter");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setIconImage(new ImageIcon(SQLFormatterEditor.class.getResource("/sf.png")) //$NON-NLS-1$
            .getImage());

    panel = getContentPane();
    panel.setLayout(new BorderLayout());

    // Create menus and toolbars
    final JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    final JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    add(toolBar, BorderLayout.NORTH);

    createFileMenu(menuBar, toolBar);
    createEditMenu(menuBar, toolBar);
    createHelpMenu(menuBar, toolBar);

    final Font font = new Font("Monospaced", Font.PLAIN, 12);

    // create text area
    textArea.setFont(font);

    // create debug area
    debugArea.setFont(font);
    debugArea.setEditable(false);
    final JLabel debugTitle = new JLabel("Simple SQL Formatter Debug");
    debugTitle.setBorder(BorderFactory.createEtchedBorder());
    final JPanel debugPanel = new JPanel(new BorderLayout());
    debugPanel.add(debugTitle, BorderLayout.NORTH);
    debugPanel.add(new JScrollPane(debugArea), BorderLayout.CENTER);

    if (debug) {
        // create split pane
        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(textArea),
                debugPanel);
        splitPane.setOneTouchExpandable(true);
        splitPane.setResizeWeight(SPLITPANEWEIGHT);

        panel.add(splitPane, BorderLayout.CENTER);
    } else {
        panel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    }

    statusBar.setBorder(BorderFactory.createEtchedBorder());
    panel.add(statusBar, BorderLayout.SOUTH);

    pack();

}

From source file:tk.tomby.tedit.plugins.explorer.TopPanel.java

/**
 * Creates a new TopPanel object./*from ww w.j av a  2 s .com*/
 *
 * @param rootDirectory DOCUMENT ME!
 */
public TopPanel(String rootDirectory) {
    super();

    setLayout(new BorderLayout());

    comboModel = new ShortedComboBoxModel(new ToStringComparator());
    comboModel.addElement(rootDirectory);
    comboModel.setSelectedItem(rootDirectory);

    combo = new JComboBox(comboModel);
    combo.setEditable(true);
    combo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String directory = (String) combo.getSelectedItem();
            comboModel.addElement(directory);
        }
    });

    ToolBarButton refresh = new ToolBarButton();
    refresh.setIconKey("explorer.top.refresh.icon");
    refresh.setToolTipKey("explorer.top.refresh.tooltip");
    refresh.setAction(new RefreshAction());

    ToolBarButton updir = new ToolBarButton();
    updir.setIconKey("explorer.top.updir.icon");
    updir.setToolTipKey("explorer.top.updir.tooltip");
    updir.setAction(new UpDirectoryAction(this));

    buttons = new JToolBar();
    buttons.setFloatable(false);
    buttons.add(updir);
    buttons.add(refresh);

    this.add(BorderLayout.NORTH, buttons);
    this.add(BorderLayout.CENTER, combo);
}

From source file:utybo.branchingstorytree.swing.editor.StoryEditor.java

public StoryEditor(BranchingStory baseStory) throws BSTException {
    setLayout(new MigLayout("hidemode 3", "[grow]", "[][grow]"));

    JToolBar toolBar = new JToolBar();
    toolBar.setBorder(null);/* w ww  . ja  va 2 s. co m*/
    toolBar.setFloatable(false);
    add(toolBar, "cell 0 0,growx");

    JButton btnSaveAs = new JButton(Lang.get("saveas"), new ImageIcon(Icons.getImage("Save As", 16)));
    btnSaveAs.addActionListener(e -> {
        saveAs();
    });
    toolBar.add(btnSaveAs);

    JButton btnSave = new JButton(Lang.get("save"), new ImageIcon(Icons.getImage("Save", 16)));
    btnSave.addActionListener(e -> {
        save();
    });
    toolBar.add(btnSave);

    JButton btnPlay = new JButton(Lang.get("play"), new ImageIcon(Icons.getImage("Circled Play", 16)));
    btnPlay.addActionListener(ev -> {
        try {
            String s = exportToString();
            File f = Files.createTempDirectory("openbst").toFile();
            File bstFile = new File(f, "expoted.bst");
            try (FileOutputStream fos = new FileOutputStream(bstFile);) {
                IOUtils.write(s, fos, StandardCharsets.UTF_8);
            }
            OpenBSTGUI.getInstance().openStory(bstFile);
        } catch (Exception e) {
            OpenBST.LOG.error("Export failed", e);
            Messagers.showException(OpenBSTGUI.getInstance(), Lang.get("editor.exportfail"), e);
        }
    });
    toolBar.add(btnPlay);

    JButton btnFilePreview = new JButton(Lang.get("editor.exportpreview"),
            new ImageIcon(Icons.getImage("PreviewText", 16)));
    btnFilePreview.addActionListener(e -> {
        try {
            String s = exportToString();
            JDialog dialog = new JDialog(OpenBSTGUI.getInstance(), Lang.get("editor.exportpreview"));
            JTextArea jta = new JTextArea(s);
            jta.setLineWrap(true);
            jta.setWrapStyleWord(true);
            dialog.add(new JScrollPane(jta));

            dialog.setModalityType(ModalityType.APPLICATION_MODAL);
            dialog.setSize((int) (Icons.getScale() * 350), (int) (Icons.getScale() * 300));
            dialog.setLocationRelativeTo(OpenBSTGUI.getInstance());
            dialog.setVisible(true);
        } catch (Exception x) {
            OpenBST.LOG.error("Failed to preview", x);
            Messagers.showException(OpenBSTGUI.getInstance(), Lang.get("editor.previewerror"), x);
        }
    });
    toolBar.add(btnFilePreview);

    Component horizontalGlue = Box.createHorizontalGlue();
    toolBar.add(horizontalGlue);

    JButton btnClose = new JButton(Lang.get("close"), new ImageIcon(Icons.getImage("Cancel", 16)));
    btnClose.addActionListener(e -> {
        askClose();
    });
    toolBar.add(btnClose);

    for (final Component component : toolBar.getComponents()) {
        if (component instanceof JButton) {
            ((JButton) component).setHideActionText(false);
            ((JButton) component).setToolTipText(((JButton) component).getText());
            ((JButton) component).setText("");
        }
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
    add(tabbedPane, "cell 0 1,grow");

    tabbedPane.addTab("Beta Warning", new StoryEditorWelcomeScreen());

    details = new StoryDetailsEditor(this);
    tabbedPane.addTab(Lang.get("editor.details"), details);

    nodesEditor = new StoryNodesEditor();
    tabbedPane.addTab(Lang.get("editor.nodes"), nodesEditor);

    this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("control S"),
            "doSave");
    this.getActionMap().put("doSave", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            save();
        }
    });

    importFrom(baseStory);
}

From source file:xtrememp.PlaylistManager.java

private void initComponents() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*from  w ww  . j a v  a 2 s  .  c  om*/
    openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON);
    openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist"));
    openPlaylistButton.addActionListener(this);
    toolBar.add(openPlaylistButton);
    savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON);
    savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist"));
    savePlaylistButton.addActionListener(this);
    toolBar.add(savePlaylistButton);
    toolBar.addSeparator();
    addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON);
    addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist"));
    addToPlaylistButton.addActionListener(this);
    toolBar.add(addToPlaylistButton);
    remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON);
    remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist"));
    remFromPlaylistButton.addActionListener(this);
    remFromPlaylistButton.setEnabled(false);
    toolBar.add(remFromPlaylistButton);
    clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON);
    clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist"));
    clearPlaylistButton.addActionListener(this);
    clearPlaylistButton.setEnabled(false);
    toolBar.add(clearPlaylistButton);
    toolBar.addSeparator();
    moveUpButton = new JButton(Utilities.GO_UP_ICON);
    moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp"));
    moveUpButton.addActionListener(this);
    moveUpButton.setEnabled(false);
    toolBar.add(moveUpButton);
    moveDownButton = new JButton(Utilities.GO_DOWN_ICON);
    moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown"));
    moveDownButton.addActionListener(this);
    moveDownButton.setEnabled(false);
    toolBar.add(moveDownButton);
    toolBar.addSeparator();
    mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON);
    mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo"));
    mediaInfoButton.addActionListener(this);
    mediaInfoButton.setEnabled(false);
    toolBar.add(mediaInfoButton);
    toolBar.add(Box.createHorizontalGlue());
    searchTextField = new SearchTextField(15);
    searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height));
    searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener());
    toolBar.add(searchTextField);
    toolBar.add(Box.createHorizontalStrut(6));
    this.add(toolBar, BorderLayout.NORTH);

    playlistTable = new JTable(playlistTableModel, playlistTableColumnModel);
    playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer());
    playlistTable.setActionMap(null);

    playlistTable.getTableHeader().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            if (SwingUtilities.isRightMouseButton(ev)
                    || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) {
                playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(),
                        ev.getY());
                return;
            }

            int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX());
            PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn);
            playlistTableColumnModel.resetAll(playlistColumn.getModelIndex());
            playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp());
            playlistTableModel.sort(playlistColumn.getComparator());

            colorizeRow();
        }
    });
    playlistTable.setFillsViewportHeight(true);
    playlistTable.setShowGrid(false);
    playlistTable.setRowSelectionAllowed(true);
    playlistTable.setColumnSelectionAllowed(false);
    playlistTable.setDragEnabled(false);
    playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD));
    playlistTable.setIntercellSpacing(new Dimension(0, 0));
    playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    playlistTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            int selectedRow = playlistTable.rowAtPoint(ev.getPoint());
            if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) {
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            }
        }
    });
    playlistTable.getSelectionModel().addListSelectionListener(this);
    playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this);
    playlistTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            // View Media Info
            if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) {
                viewMediaInfo();
            } // Select all
            else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) {
                playlistTable.selectAll();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                // Move selected track(s) up
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveUp();
                } // Select previous track
                else {
                    if (playlistTable.getSelectedRow() > 0) {
                        int previousRowIndex = playlistTable.getSelectedRow() - 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex);
                        makeRowVisible(previousRowIndex);
                    }
                }
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                // Move selected track(s) down
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveDown();
                } // Select next track
                else {
                    if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) {
                        int nextRowIndex = playlistTable.getSelectedRow() + 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex);
                        makeRowVisible(nextRowIndex);
                    }
                }
            } // Play selected track
            else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                int selectedRow = playlistTable.getSelectedRow();
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            } // Add new tracks
            else if (e.getKeyCode() == KeyEvent.VK_INSERT) {
                addFilesDialog(false);
            } // Delete selected tracks
            else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                remove();
            }
        }
    });
    XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this));
    JScrollPane ptScrollPane = new JScrollPane(playlistTable);
    ptScrollPane.setActionMap(null);
    this.add(ptScrollPane, BorderLayout.CENTER);
}