Search in sources :

Example 1 with TransferHandler

use of javax.swing.TransferHandler in project jna by java-native-access.

the class AlphaMaskDemo2 method run.

public void run() {
    // Must find a graphics configuration with a depth of 32 bits
    GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
    frame = new JFrame("Alpha Mask Demo");
    alphaWindow = new JWindow(frame, gconfig);
    icon = new JLabel();
    icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    alphaWindow.getContentPane().add(icon);
    JButton quit = new JButton("Quit");
    JLabel label = new JLabel("Drag this window by its image");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    alphaWindow.getContentPane().add(label, BorderLayout.NORTH);
    alphaWindow.getContentPane().add(quit, BorderLayout.SOUTH);
    quit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    MouseInputAdapter handler = new MouseInputAdapter() {

        private Point offset;

        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e))
                offset = e.getPoint();
        }

        public void mouseReleased(MouseEvent e) {
            offset = null;
        }

        public void mouseDragged(MouseEvent e) {
            if (offset != null) {
                Window w = (Window) e.getSource();
                Point where = e.getPoint();
                where.translate(-offset.x, -offset.y);
                Point loc = w.getLocationOnScreen();
                loc.translate(where.x, where.y);
                w.setLocation(loc.x, loc.y);
            }
        }
    };
    alphaWindow.addMouseListener(handler);
    alphaWindow.addMouseMotionListener(handler);
    JPanel p = new JPanel(new BorderLayout(8, 8));
    p.setBorder(new EmptyBorder(8, 8, 8, 8));
    p.setTransferHandler(new TransferHandler() {

        private static final long serialVersionUID = 1L;

        public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
            List<DataFlavor> list = Arrays.asList(transferFlavors);
            if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR) || list.contains(DataFlavor.imageFlavor) || list.contains(DataFlavor.javaFileListFlavor)) {
                return true;
            }
            if (DataFlavor.selectBestTextFlavor(transferFlavors) != null) {
                return true;
            }
            System.err.println("No acceptable flavor found in " + Arrays.asList(transferFlavors));
            return false;
        }

        public boolean importData(JComponent comp, Transferable t) {
            try {
                if (t.isDataFlavorSupported(URL_FLAVOR)) {
                    URL url = (URL) t.getTransferData(URL_FLAVOR);
                    setImage(Toolkit.getDefaultToolkit().getImage(url));
                    return true;
                }
                if (t.isDataFlavorSupported(URI_LIST_FLAVOR)) {
                    String s = (String) t.getTransferData(URI_LIST_FLAVOR);
                    String[] uris = s.split("[\r\n]");
                    if (uris.length > 0) {
                        URL url = new URL(uris[0]);
                        setImage(Toolkit.getDefaultToolkit().getImage(url));
                        return true;
                    }
                    return false;
                }
                if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                    Image image = (Image) t.getTransferData(DataFlavor.imageFlavor);
                    setImage(image);
                    return true;
                }
                if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                    List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
                    File f = files.get(0);
                    URL url = new URL("file://" + f.toURI().toURL().getPath());
                    Image image = Toolkit.getDefaultToolkit().getImage(url);
                    setImage(image);
                    return true;
                }
                DataFlavor flavor = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors());
                if (flavor != null) {
                    Reader reader = flavor.getReaderForText(t);
                    char[] buf = new char[512];
                    StringBuilder b = new StringBuilder();
                    int count;
                    // encoding wrong
                    while ((count = reader.read(buf)) > 0) {
                        for (int i = 0; i < count; i++) {
                            if (buf[i] != 0)
                                b.append(buf, i, 1);
                        }
                    }
                    String html = b.toString();
                    Pattern p = Pattern.compile("<img.*src=\"([^\\\"\">]+)\"", Pattern.CANON_EQ | Pattern.UNICODE_CASE);
                    Matcher m = p.matcher(html);
                    if (m.find()) {
                        URL url = new URL(m.group(1));
                        System.out.println("Load image from " + url);
                        Image image = Toolkit.getDefaultToolkit().getImage(url);
                        setImage(image);
                        return true;
                    }
                    System.err.println("Can't parse text: " + html);
                    return false;
                }
                System.err.println("No flavor available: " + Arrays.asList(t.getTransferDataFlavors()));
            } catch (UnsupportedFlavorException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            return false;
        }
    });
    p.add(new JLabel("<html><center>Drop an image with an alpha channel onto this window<br>" + "You may also adjust the overall transparency with the slider</center></html>"), BorderLayout.NORTH);
    p.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    final JSlider slider = new JSlider(0, 255, 255);
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int value = slider.getValue();
            WindowUtils.setWindowAlpha(alphaWindow, value / 255f);
        }
    });
    p.add(slider, BorderLayout.SOUTH);
    frame.getContentPane().add(p);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    centerOnScreen(frame);
    frame.setVisible(true);
    WindowUtils.setWindowTransparent(alphaWindow, true);
    alphaWindow.setLocation(frame.getX() + frame.getWidth() + 4, frame.getY());
    try {
        URL url = getClass().getResource("tardis.png");
        if (url != null) {
            setImage(Toolkit.getDefaultToolkit().getImage(url));
        }
    } catch (Exception e) {
    }
}
Also used : JPanel(javax.swing.JPanel) Matcher(java.util.regex.Matcher) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Reader(java.io.Reader) Image(java.awt.Image) URL(java.net.URL) GraphicsConfiguration(java.awt.GraphicsConfiguration) DataFlavor(java.awt.datatransfer.DataFlavor) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JSlider(javax.swing.JSlider) List(java.util.List) ChangeListener(javax.swing.event.ChangeListener) EmptyBorder(javax.swing.border.EmptyBorder) Window(java.awt.Window) JWindow(javax.swing.JWindow) Pattern(java.util.regex.Pattern) MouseEvent(java.awt.event.MouseEvent) JWindow(javax.swing.JWindow) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JLabel(javax.swing.JLabel) Point(java.awt.Point) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) TransferHandler(javax.swing.TransferHandler) File(java.io.File) MouseInputAdapter(javax.swing.event.MouseInputAdapter)

Example 2 with TransferHandler

use of javax.swing.TransferHandler in project jabref by JabRef.

the class JabRefFrame method initLayout.

private void initLayout() {
    tabbedPane.putClientProperty(Options.NO_CONTENT_BORDER_KEY, Boolean.TRUE);
    setProgressBarVisible(false);
    pushApplications = new PushToApplications();
    pushExternalButton = new PushToApplicationButton(this, pushApplications.getApplications());
    fillMenu();
    createToolBar();
    setJMenuBar(mb);
    getContentPane().setLayout(new BorderLayout());
    JPanel toolbarPanel = new JPanel(new WrapLayout(FlowLayout.LEFT));
    toolbarPanel.add(tlb);
    toolbarPanel.add(globalSearchBar);
    getContentPane().add(toolbarPanel, BorderLayout.PAGE_START);
    splitPane.setDividerSize(2);
    splitPane.setBorder(null);
    splitPane.setRightComponent(tabbedPane);
    splitPane.setLeftComponent(sidePaneManager.getPanel());
    getContentPane().add(splitPane, BorderLayout.CENTER);
    UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
    sidePaneManager.updateView();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.BOTH;
    con.anchor = GridBagConstraints.WEST;
    JPanel status = new JPanel();
    status.setLayout(gbl);
    con.weighty = 0;
    con.weightx = 0;
    con.gridwidth = 1;
    con.insets = new Insets(0, 2, 0, 0);
    gbl.setConstraints(statusLabel, con);
    status.add(statusLabel);
    con.weightx = 1;
    con.insets = new Insets(0, 4, 0, 0);
    con.gridwidth = 1;
    gbl.setConstraints(statusLine, con);
    status.add(statusLine);
    con.weightx = 0;
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.insets = new Insets(2, 4, 2, 2);
    gbl.setConstraints(progressBar, con);
    status.add(progressBar);
    statusLabel.setForeground(GUIGlobals.ENTRY_EDITOR_LABEL_COLOR.darker());
    getContentPane().add(status, BorderLayout.PAGE_END);
    // Drag and drop for tabbedPane:
    TransferHandler xfer = new EntryTableTransferHandler(null, this, null);
    tabbedPane.setTransferHandler(xfer);
    tlb.setTransferHandler(xfer);
    mb.setTransferHandler(xfer);
    sidePaneManager.getPanel().setTransferHandler(xfer);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) EntryTableTransferHandler(org.jabref.gui.groups.EntryTableTransferHandler) Insets(java.awt.Insets) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) PushToApplications(org.jabref.gui.push.PushToApplications) EntryTableTransferHandler(org.jabref.gui.groups.EntryTableTransferHandler) TransferHandler(javax.swing.TransferHandler) PushToApplicationButton(org.jabref.gui.push.PushToApplicationButton)

Example 3 with TransferHandler

use of javax.swing.TransferHandler in project JMRI by JMRI.

the class RosterFrame method createTop.

JComponent createTop() {
    Object selectedRosterGroup = prefsMgr.getProperty(getWindowFrameRef(), SELECTED_ROSTER_GROUP);
    groups = new RosterGroupsPanel((selectedRosterGroup != null) ? selectedRosterGroup.toString() : null);
    groups.setNewWindowMenuAction(this.getNewWindowAction());
    setTitle(groups.getSelectedRosterGroup());
    final JPanel rosters = new JPanel();
    rosters.setLayout(new BorderLayout());
    // set up roster table
    rtable = new RosterTable(true, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    rtable.setRosterGroup(this.getSelectedRosterGroup());
    rtable.setRosterGroupSource(groups);
    rosters.add(rtable, BorderLayout.CENTER);
    // add selection listener
    rtable.getTable().getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
        JTable table = rtable.getTable();
        if (!e.getValueIsAdjusting()) {
            if (rtable.getSelectedRosterEntries().length == 1 && table.getSelectedRow() >= 0) {
                log.debug("Selected row ", table.getSelectedRow());
                locoSelected(rtable.getModel().getValueAt(table.getRowSorter().convertRowIndexToModel(table.getSelectedRow()), RosterTableModel.IDCOL).toString());
            } else if (rtable.getSelectedRosterEntries().length > 1 || table.getSelectedRow() < 0) {
                locoSelected(null);
            }
        // leave last selected item visible if no selection
        }
    });
    //Set all the sort and width details of the table first.
    String rostertableref = getWindowFrameRef() + ":roster";
    rtable.getTable().setName(rostertableref);
    // Allow only one column to be sorted at a time - 
    // Java allows multiple column sorting, but to effectly persist that, we
    // need to be intelligent about which columns can be meaningfully sorted
    // with other columns; this bypasses the problem by only allowing the
    // last column sorted to affect sorting
    RowSorterUtil.addSingleSortableColumnListener(rtable.getTable().getRowSorter());
    // Reset and then persist the table's ui state
    JTablePersistenceManager tpm = InstanceManager.getNullableDefault(JTablePersistenceManager.class);
    if (tpm != null) {
        tpm.resetState(rtable.getTable());
        tpm.persist(rtable.getTable());
    }
    rtable.getTable().setDragEnabled(true);
    rtable.getTable().setTransferHandler(new TransferHandler() {

        @Override
        public int getSourceActions(JComponent c) {
            return TransferHandler.COPY;
        }

        @Override
        public Transferable createTransferable(JComponent c) {
            JTable table = rtable.getTable();
            ArrayList<String> Ids = new ArrayList<>(table.getSelectedRowCount());
            for (int i = 0; i < table.getSelectedRowCount(); i++) {
                Ids.add(rtable.getModel().getValueAt(table.getRowSorter().convertRowIndexToModel(table.getSelectedRows()[i]), RosterTableModel.IDCOL).toString());
            }
            return new RosterEntrySelection(Ids);
        }

        @Override
        public void exportDone(JComponent c, Transferable t, int action) {
        // nothing to do
        }
    });
    MouseListener rosterMouseListener = new rosterPopupListener();
    rtable.getTable().addMouseListener(rosterMouseListener);
    try {
        clickDelay = ((Integer) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"));
    } catch (RuntimeException e) {
        clickDelay = 500;
        log.debug("Unable to get the double click speed, Using JMRI default of half a second" + e.toString());
    }
    // assemble roster/groups splitpane
    rosterGroupSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, groups, rosters);
    rosterGroupSplitPane.setOneTouchExpandable(true);
    // emphasis rosters
    rosterGroupSplitPane.setResizeWeight(0);
    Object w = prefsMgr.getProperty(getWindowFrameRef(), "rosterGroupPaneDividerLocation");
    if (w != null) {
        groupSplitPaneLocation = (Integer) w;
        rosterGroupSplitPane.setDividerLocation(groupSplitPaneLocation);
    }
    if (!Roster.getDefault().getRosterGroupList().isEmpty()) {
        if (prefsMgr.getSimplePreferenceState(this.getClass().getName() + ".hideGroups")) {
            hideGroupsPane(true);
        }
    } else {
        enableRosterGroupMenuItems(false);
    }
    PropertyChangeListener propertyChangeListener = (PropertyChangeEvent changeEvent) -> {
        JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
        String propertyName = changeEvent.getPropertyName();
        if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
            int current = sourceSplitPane.getDividerLocation();
            hideGroups = current <= 1;
            Integer last = (Integer) changeEvent.getNewValue();
            if (current >= 2) {
                groupSplitPaneLocation = current;
            } else if (last >= 2) {
                groupSplitPaneLocation = last;
            }
        }
    };
    groups.addPropertyChangeListener(SELECTED_ROSTER_GROUP, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            prefsMgr.setProperty(this.getClass().getName(), SELECTED_ROSTER_GROUP, pce.getNewValue());
            setTitle((String) pce.getNewValue());
        }
    });
    rosterGroupSplitPane.addPropertyChangeListener(propertyChangeListener);
    Roster.getDefault().addPropertyChangeListener((PropertyChangeEvent e) -> {
        if (e.getPropertyName().equals("RosterGroupAdded") && Roster.getDefault().getRosterGroupList().size() == 1) {
            // if the pane is hidden, show it when 1st group is created
            hideGroupsPane(false);
            enableRosterGroupMenuItems(true);
        } else if (!rtable.isVisible() && (e.getPropertyName().equals("saved"))) {
            if (firstHelpLabel != null) {
                firstHelpLabel.setVisible(false);
            }
            rtable.setVisible(true);
            rtable.resetColumnWidths();
        }
    });
    if (Roster.getDefault().numEntries() == 0) {
        try {
            BufferedImage myPicture = ImageIO.read(FileUtil.findURL(("resources/" + Bundle.getMessage("ThrottleFirstUseImage")), FileUtil.Location.INSTALLED));
            //rosters.add(new JLabel(new ImageIcon( myPicture )), BorderLayout.CENTER);
            firstHelpLabel = new JLabel(new ImageIcon(myPicture));
            rtable.setVisible(false);
            rosters.add(firstHelpLabel, BorderLayout.NORTH);
            //tableArea.add(firstHelpLabel);
            rtable.setVisible(false);
        } catch (IOException ex) {
        // handle exception...
        }
    }
    return rosterGroupSplitPane;
}
Also used : RosterEntrySelection(jmri.util.datatransfer.RosterEntrySelection) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) PropertyChangeListener(java.beans.PropertyChangeListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) BufferedImage(java.awt.image.BufferedImage) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) PropertyChangeEvent(java.beans.PropertyChangeEvent) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JLabel(javax.swing.JLabel) IOException(java.io.IOException) JTablePersistenceManager(jmri.swing.JTablePersistenceManager) JTable(javax.swing.JTable) TransferHandler(javax.swing.TransferHandler) JSplitPane(javax.swing.JSplitPane)

Example 4 with TransferHandler

use of javax.swing.TransferHandler in project knime-core by knime.

the class DnDColumnSelectionSearchableListPanel method enableDragAndDropSupport.

/**
 * Convenient method to enable the drag and drop support of the list view at the left side.
 *
 * @param dndStateListener notified if drag is started and finished
 * @since 2.11
 */
public void enableDragAndDropSupport(final DnDStateListener dndStateListener) {
    ColumnSelectionList columnList = getColumnList();
    columnList.setDragEnabled(true);
    JPopupMenu popup = new JPopupMenu();
    final JMenuItem jMenuItem = new JMenuItem("New Configuration", DnDConfigurationPanel.ADD_ICON_16);
    popup.add(jMenuItem);
    popup.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
            boolean enable = true;
            for (DataColumnSpec col : getSelectedColumns()) {
                if (m_configuredColumnDeterminer.isConfiguredColumn(col)) {
                    enable = false;
                    break;
                }
            }
            jMenuItem.setEnabled(enable);
        }

        @Override
        public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(final PopupMenuEvent e) {
        }
    });
    jMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            fireConfigurationRequested(Type.CREATION);
        }
    });
    columnList.setComponentPopupMenu(popup);
    final TransferHandler handler = columnList.getTransferHandler();
    columnList.setTransferHandler(new DnDColumnSpecSourceTransferHandler(handler, dndStateListener) {

        @Override
        protected List<DataColumnSpec> getColumnsSpecsToDrag() {
            return getSelectedColumns();
        }
    });
}
Also used : ColumnSelectionList(org.knime.core.node.util.ColumnSelectionList) DataColumnSpec(org.knime.core.data.DataColumnSpec) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) PopupMenuListener(javax.swing.event.PopupMenuListener) TransferHandler(javax.swing.TransferHandler) List(java.util.List) ColumnSelectionList(org.knime.core.node.util.ColumnSelectionList) JMenuItem(javax.swing.JMenuItem) PopupMenuEvent(javax.swing.event.PopupMenuEvent) JPopupMenu(javax.swing.JPopupMenu)

Example 5 with TransferHandler

use of javax.swing.TransferHandler in project pdfbox by apache.

the class PDFDebugger method initComponents.

/**
 * This method is called from within the constructor to initialize the form.
 */
private void initComponents() {
    jSplitPane1 = new javax.swing.JSplitPane();
    jScrollPane1 = new JScrollPane();
    tree = new Tree(this);
    jScrollPane2 = new JScrollPane();
    jTextPane1 = new javax.swing.JTextPane();
    tree.setCellRenderer(new PDFTreeCellRenderer());
    tree.setModel(null);
    setTitle("Apache PDFBox Debugger");
    addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent windowEvent) {
            tree.requestFocusInWindow();
            super.windowOpened(windowEvent);
        }

        @Override
        public void windowClosing(WindowEvent evt) {
            exitForm(evt);
        }
    });
    jScrollPane1.setBorder(new BevelBorder(BevelBorder.RAISED));
    jScrollPane1.setPreferredSize(new Dimension(350, 500));
    tree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent evt) {
            jTree1ValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(tree);
    jSplitPane1.setRightComponent(jScrollPane2);
    jSplitPane1.setDividerSize(3);
    jScrollPane2.setPreferredSize(new Dimension(300, 500));
    jScrollPane2.setViewportView(jTextPane1);
    jSplitPane1.setLeftComponent(jScrollPane1);
    JScrollPane documentScroller = new JScrollPane();
    documentScroller.setViewportView(documentPanel);
    statusPane = new TreeStatusPane(tree);
    statusPane.getPanel().setBorder(new BevelBorder(BevelBorder.RAISED));
    statusPane.getPanel().setPreferredSize(new Dimension(300, 25));
    getContentPane().add(statusPane.getPanel(), BorderLayout.PAGE_START);
    getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    statusBar = new ReaderBottomPanel();
    getContentPane().add(statusBar, BorderLayout.SOUTH);
    // create menus
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(createFileMenu());
    menuBar.add(createEditMenu());
    ViewMenu viewMenu = ViewMenu.getInstance(this);
    menuBar.add(viewMenu.getMenu());
    setJMenuBar(menuBar);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int width = 1000;
    int height = 970;
    setBounds((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height);
    // drag and drop to open files
    setTransferHandler(new TransferHandler() {

        @Override
        public boolean canImport(TransferSupport transferSupport) {
            return transferSupport.isDataFlavorSupported(DataFlavor.javaFileListFlavor);
        }

        @Override
        @SuppressWarnings("unchecked")
        public boolean importData(TransferSupport transferSupport) {
            try {
                Transferable transferable = transferSupport.getTransferable();
                List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
                readPDFFile(files.get(0), "");
                return true;
            } catch (IOException e) {
                new ErrorDialog(e).setVisible(true);
                return true;
            } catch (UnsupportedFlavorException e) {
                throw new RuntimeException(e);
            }
        }
    });
    // Mac OS X file open/quit handler
    if (IS_MAC_OS && !isMinJdk9()) {
        // TODO this needs to be rewritten for JDK9, see PDFBOX-4013
        try {
            Method osxOpenFiles = getClass().getDeclaredMethod("osxOpenFiles", String.class);
            osxOpenFiles.setAccessible(true);
            OSXAdapter.setFileHandler(this, osxOpenFiles);
            Method osxQuit = getClass().getDeclaredMethod("osxQuit");
            osxQuit.setAccessible(true);
            OSXAdapter.setQuitHandler(this, osxQuit);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : BevelBorder(javax.swing.border.BevelBorder) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeStatusPane(org.apache.pdfbox.debugger.treestatus.TreeStatusPane) PDFTreeCellRenderer(org.apache.pdfbox.debugger.ui.PDFTreeCellRenderer) Tree(org.apache.pdfbox.debugger.ui.Tree) ViewMenu(org.apache.pdfbox.debugger.ui.ViewMenu) List(java.util.List) JScrollPane(javax.swing.JScrollPane) Transferable(java.awt.datatransfer.Transferable) ErrorDialog(org.apache.pdfbox.debugger.ui.ErrorDialog) Dimension(java.awt.Dimension) IOException(java.io.IOException) Method(java.lang.reflect.Method) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) WindowEvent(java.awt.event.WindowEvent) TransferHandler(javax.swing.TransferHandler) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) ReaderBottomPanel(org.apache.pdfbox.debugger.ui.ReaderBottomPanel) File(java.io.File) JMenuBar(javax.swing.JMenuBar)

Aggregations

TransferHandler (javax.swing.TransferHandler)14 List (java.util.List)8 Transferable (java.awt.datatransfer.Transferable)7 IOException (java.io.IOException)7 JComponent (javax.swing.JComponent)7 File (java.io.File)6 JPanel (javax.swing.JPanel)6 BorderLayout (java.awt.BorderLayout)5 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)5 ActionEvent (java.awt.event.ActionEvent)5 ActionListener (java.awt.event.ActionListener)5 JLabel (javax.swing.JLabel)5 DataFlavor (java.awt.datatransfer.DataFlavor)4 ArrayList (java.util.ArrayList)4 JFrame (javax.swing.JFrame)4 Dimension (java.awt.Dimension)3 Image (java.awt.Image)3 Point (java.awt.Point)3 MouseEvent (java.awt.event.MouseEvent)3 JPopupMenu (javax.swing.JPopupMenu)3