Java Code Examples for java.awt.dnd.DropTarget#addDropTargetListener()
The following examples show how to use
java.awt.dnd.DropTarget#addDropTargetListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: mxGraphHandler.java From blog-codes with Apache License 2.0 | 6 votes |
/** * */ protected void installDropTargetHandler() { DropTarget dropTarget = graphComponent.getDropTarget(); try { if (dropTarget != null) { dropTarget.addDropTargetListener(this); currentDropTarget = dropTarget; } } catch (TooManyListenersException e) { // should not happen... swing drop target is multicast log.log(Level.SEVERE, "Failed to install drop target handler", e); } }
Example 2
Source File: TraceTabbedPane.java From pega-tracerviewer with Apache License 2.0 | 6 votes |
public TraceTabbedPane(TracerViewerSetting tracerViewerSetting, RecentFileContainer recentFileContainer) { super(); this.tracerViewerSetting = tracerViewerSetting; this.recentFileContainer = recentFileContainer; fileTabIndexMap = new LinkedHashMap<String, Integer>(); setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); normalBorder = getBorder(); try { DropTarget dt = new DropTarget(); dt.addDropTargetListener(this); setDropTarget(dt); } catch (TooManyListenersException e) { LOG.error("Error adding drag drop listener", e); } }
Example 3
Source File: DarkTabbedPaneUI.java From darklaf with MIT License | 5 votes |
protected void installDragSupport() { tabPane.setTransferHandler(TRANSFER_HANDLER); try { DropTarget target = tabPane.getDropTarget(); if (target != null) { target.addDropTargetListener(TRANSFER_HANDLER); target.setActive(dndEnabled); } } catch (TooManyListenersException e) { e.printStackTrace(); } }
Example 4
Source File: DarkTabFrameUI.java From darklaf with MIT License | 5 votes |
protected void installDnD() { tabFrame.setTransferHandler(TRANSFER_HANDLER); try { DropTarget dropTarget = tabFrame.getDropTarget(); if (dropTarget != null) { dropTarget.addDropTargetListener(TRANSFER_HANDLER); dropTarget.setActive(tabFrame.isDndEnabled()); } } catch (TooManyListenersException e) { e.printStackTrace(); } }
Example 5
Source File: EditorRuler.java From blog-codes with Apache License 2.0 | 5 votes |
/** * Constructs a new ruler for the specified graph and orientation. * * @param graph * The graph to create the ruler for. * @param orientation * The orientation to use for the ruler. */ public EditorRuler(mxGraphComponent graphComponent, int orientation) { this.orientation = orientation; this.graphComponent = graphComponent; updateIncrementAndUnits(); graphComponent.getGraph().getView().addListener( mxEvent.SCALE, repaintHandler); graphComponent.getGraph().getView().addListener( mxEvent.TRANSLATE, repaintHandler); graphComponent.getGraph().getView().addListener( mxEvent.SCALE_AND_TRANSLATE, repaintHandler); graphComponent.getGraphControl().addMouseMotionListener(this); DropTarget dropTarget = graphComponent.getDropTarget(); try { if (dropTarget != null) { dropTarget.addDropTargetListener(this); } } catch (TooManyListenersException tmle) { // should not happen... swing drop target is multicast } setBorder(BorderFactory.createLineBorder(Color.black)); }
Example 6
Source File: FileDropDecorator.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
private void makeDropTarget(final Component c) { final DropTarget dt = new DropTarget(); try { dt.addDropTargetListener( dropListener ); } catch(TooManyListenersException e ) { logger.error("Do you have another listener attached ?",e); } c.addHierarchyListener( ( HierarchyEvent evt )->{ Component parent = c.getParent(); if( parent == null ) c.setDropTarget( null ); else new DropTarget(c, dropListener); }); if( c.getParent() != null ) new DropTarget(c, dropListener); if( c instanceof Container ) { Container cont = (Container) c; for(Component cp : cont.getComponents()) makeDropTarget(cp ); } }
Example 7
Source File: MainWindow.java From Luyten with Apache License 2.0 | 4 votes |
public MainWindow(File fileFromCommandLine) { configSaver = ConfigSaver.getLoadedInstance(); windowPosition = configSaver.getMainWindowPosition(); luytenPrefs = configSaver.getLuytenPreferences(); mainMenuBar = new MainMenuBar(this); this.setJMenuBar(mainMenuBar); this.adjustWindowPositionBySavedState(); this.setHideFindBoxOnMainWindowFocus(); this.setShowFindAllBoxOnMainWindowFocus(); this.setQuitOnWindowClosing(); this.setTitle(TITLE); this.setIconImage(new ImageIcon( Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/resources/Luyten.png"))).getImage()); JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); label = new JLabel(); label.setHorizontalAlignment(JLabel.LEFT); panel1.setBorder(new BevelBorder(BevelBorder.LOWERED)); panel1.setPreferredSize(new Dimension(this.getWidth() / 2, 20)); panel1.add(label); JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bar = new JProgressBar(); bar.setStringPainted(true); bar.setOpaque(false); bar.setVisible(false); panel2.setPreferredSize(new Dimension(this.getWidth() / 3, 20)); panel2.add(bar); model = new Model(this); this.getContentPane().add(model); JSplitPane spt = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2) { private static final long serialVersionUID = 2189946972124687305L; private final int location = 400; { setDividerLocation(location); } @Override public int getDividerLocation() { return location; } @Override public int getLastDividerLocation() { return location; } }; spt.setBorder(new BevelBorder(BevelBorder.LOWERED)); spt.setPreferredSize(new Dimension(this.getWidth(), 24)); this.add(spt, BorderLayout.SOUTH); if (fileFromCommandLine != null) { model.loadFile(fileFromCommandLine); } try { DropTarget dt = new DropTarget(); dt.addDropTargetListener(new DropListener(this)); this.setDropTarget(dt); } catch (Exception e) { Luyten.showExceptionDialog("Exception!", e); } fileDialog = new FileDialog(this); fileSaver = new FileSaver(bar, label); this.setExitOnEscWhenEnabled(model); if (fileFromCommandLine == null || fileFromCommandLine.getName().toLowerCase().endsWith(".jar") || fileFromCommandLine.getName().toLowerCase().endsWith(".zip")) { model.startWarmUpThread(); } if(RecentFiles.load() > 0) mainMenuBar.updateRecentFiles(); }