List of usage examples for java.awt.dnd DropTarget DropTarget
public DropTarget(Component c, DropTargetListener dtl) throws HeadlessException
From source file:TreeTester.java
public DndTree(TreeModel model) { super(model); DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new TreeDragGestureListener()); DropTarget dropTarget = new DropTarget(this, new TreeDropTargetListener()); }
From source file:de.tor.tribes.ui.algo.AttackTimePanel.java
/** * Creates new form TestPanel// ww w. j a v a 2s .c o m * * @param pListener */ public AttackTimePanel(SettingsChangedListener pListener) { initComponents(); mListener = pListener; dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(jLabel5, DnDConstants.ACTION_COPY_OR_MOVE, AttackTimePanel.this); dragSource.createDefaultDragGestureRecognizer(jLabel6, DnDConstants.ACTION_COPY_OR_MOVE, AttackTimePanel.this); DropTarget dropTarget = new DropTarget(this, this); jTimeFrameList.setDropTarget(dropTarget); jSendTimeFrame.addColorisationListener(new ColorisationListener() { @Override public void newColors(ColorisationEvent ColorisationEvent_Arg) { updatePreview(); } }); dateTimeField.setActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updatePreview(); } }); jTimeFrameList.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { deleteSelectedTimeSpan(); } } }); jArriveInPastLabel.setVisible(false); maxArriveTimeField.setActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TimeFrame currentFrame = getTimeFrame(); if (currentFrame != null) { jArriveInPastLabel .setVisible(currentFrame.getArriveRange().getMaximum() < System.currentTimeMillis()); } } }); reset(); updatePreview(); }
From source file:com.mirth.connect.client.ui.components.MirthTree.java
public MirthTree(MirthTreeNode root, String prefix, String suffix) { this.parent = PlatformUI.MIRTH_FRAME; setCellRenderer(new DefaultTreeCellRenderer() { @Override//from w w w .j a v a 2s . co m public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { setFont(UIConstants.MONOSPACED_FONT); putClientProperty("html.disable", Boolean.TRUE); return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); } }); mf = new MyFilter(); ftm = new FilterTreeModel(root, mf); this.setModel(ftm); dropTarget = new DropTarget(this, this); this.prefix = prefix; this.suffix = suffix; if (prefix != null) { if (prefix.equals(MessageTreePanel.MAPPER_PREFIX)) { this.supportedDropFlavor = TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR; } else if (prefix.equals(MessageTreePanel.MESSAGE_BUILDER_PREFIX)) { this.supportedDropFlavor = TreeTransferable.MAPPER_DATA_FLAVOR; } } }
From source file:de.tor.tribes.ui.windows.AbstractDSWorkbenchFrame.java
public AbstractDSWorkbenchFrame() { mFrameListeners = new LinkedList<>(); // getContentPane().setBackground(Constants.DS_BACK); dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); DropTarget dropTarget = new DropTarget(this, this); this.setDropTarget(dropTarget); }
From source file:modmanager.MainWindow.java
private void registerDnD() { ModInstallerDragAndDropListener lis = new ModInstallerDragAndDropListener(modifications); DropTarget trg = new DropTarget(this, lis); }
From source file:com.o2d.pkayjava.editor.Main.java
private void startLoadingEditor() { //first, kill off the splash if (!(SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_UNIX)) { splash.kill();/*w ww . j a va 2 s. c o m*/ } Overlap2D overlap2D = new Overlap2D(); Rectangle maximumWindowBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); double width = maximumWindowBounds.getWidth(); double height = maximumWindowBounds.getHeight(); if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Overlap2D"); JglfwApplicationConfiguration config = new JglfwApplicationConfiguration(); config.width = (int) (width); config.height = (int) (height - height * .04); config.backgroundFPS = 0; config.title = "Overlap2D - Public Alpha v" + AppConfig.getInstance().version; new JglfwApplication(overlap2D, config); } else { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Overlap2D - Public Alpha v" + AppConfig.getInstance().version; config.fullscreen = true; config.resizable = false; config.width = (int) (width); config.height = (int) (height - height * .04); config.backgroundFPS = 0; mainFrame = new LwjglFrame(overlap2D, config); mainFrame.setExtendedState(mainFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH); toggleVisible(); // subscribe to file dropping notifications, currently windows only DropTarget dropTarget = new DropTarget(mainFrame, new FileDropListener()); } if (!SystemUtils.IS_OS_UNIX) { // no aesthetics for linux users I guess.. setIcon(); } }
From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java
public TokenCompositionPanel() { setLayout(new PositionalLayout()); setFocusable(true);/*from w w w . j ava 2 s .c o m*/ // DnD new DropTarget(this, this); addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); addKeyListener(this); changeObservers = new ChangeObservable(); }
From source file:dataviewer.DataViewer.java
/** * Creates new form DataViewer//from www . j ava 2 s . c o m */ public DataViewer() { try { for (Enum ee : THREAD.values()) { t[ee.ordinal()] = new Thread(); } initComponents(); DropTarget dropTarget = new DropTarget(tr_files, new DropTargetListenerImpl()); TreeSelectionListener treeSelectionListener = new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { javax.swing.JTree tree = (javax.swing.JTree) e.getSource(); TreePath path = tree.getSelectionPath(); Object[] pnode = (Object[]) path.getPath(); String name = pnode[pnode.length - 1].toString(); String ex = getExtension(name); if (ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) { selected_file = name; } else { selected_file = ""; } } }; tr_files.addTreeSelectionListener(treeSelectionListener); tr_files.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() >= 2) { if (!"".equals(selected_file)) { //count_data(); read_data(); } else { TreePath path = tr_files.getSelectionPath(); if (path.getLastPathComponent().toString().equals(cur_path)) { cur_path = (new File(cur_path)).getParent(); } else { cur_path = cur_path + File.separator + path.getLastPathComponent().toString(); } fill_tree(); } } } }); tr_files.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE) { cur_path = (new File(cur_path)).getParent(); fill_tree(); } else if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (!"".equals(selected_file)) { //count_data(); read_data(); } else { TreePath path = tr_files.getSelectionPath(); if (path.getLastPathComponent().toString().equals(cur_path)) { cur_path = (new File(cur_path)).getParent(); } else { cur_path = cur_path + File.separator + path.getLastPathComponent().toString(); } fill_tree(); } } else if (evt.getKeyCode() == KeyEvent.VK_DELETE) { if (!"".equals(selected_file)) { String name = cur_path + File.separator + selected_file; if ((new File(name)).isFile()) { int dialogResult = JOptionPane.showConfirmDialog(null, "Selected file [" + selected_file + "] will be removed and not recoverable.", "Are you sure?", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.YES_OPTION) { (new File(name)).delete(); fill_tree(); } } } else { JOptionPane.showMessageDialog(null, "For safety concern, removing folder is not supported.", "Information", JOptionPane.ERROR_MESSAGE); } } } }); tr_files.setCellRenderer(new MyTreeCellRenderer()); p_count.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); //tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrl1, "tab_read"); //tp_menu.getActionMap().put("tab_read", (Action) new ActionListenerImpl()); //tp_menu.setMnemonicAt(0, KeyEvent.VK_1); //tp_menu.setMnemonicAt(1, KeyEvent.VK_2); /*InputMap inputMap = tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = tp_menu.getActionMap(); KeyStroke ctrl1 = KeyStroke.getKeyStroke("ctrl 1"); inputMap.put(ctrl1, "tab_read"); actionMap.put("tab_read", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { tp_menu.setSelectedIndex(0); } }); KeyStroke ctrl2 = KeyStroke.getKeyStroke("ctrl 2"); inputMap.put(ctrl2, "tab_analyze"); actionMap.put("tab_analyze", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { tp_menu.setSelectedIndex(1); } });*/ config(); } catch (Exception e) { txt_count.setText(e.getMessage()); } }
From source file:com.mirth.connect.client.ui.TemplatePanel.java
public TemplatePanel(MirthEditorPane m) { this.parent = m; initComponents();/* w ww .ja v a2 s .c o m*/ openFileButton.setIcon(UIConstants.ICON_FILE_PICKER); if (PlatformUI.MIRTH_FRAME != null) { dataTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel( PlatformUI.MIRTH_FRAME.dataTypeToDisplayName.values().toArray())); } hl7Document = new SyntaxDocument(); hl7Document.setTokenMarker(new HL7TokenMarker()); pasteBox.setDocument(hl7Document); // handles updating the tree pasteBox.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateText(); } public void insertUpdate(DocumentEvent e) { updateText(); } public void removeUpdate(DocumentEvent e) { updateText(); } }); pasteBox.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON2) { if (pasteBox.getText().equals(DEFAULT_TEXT)) { pasteBox.setText(""); } } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON2) { if (pasteBox.getText().length() == 0) { pasteBox.setText(DEFAULT_TEXT); } } } }); new DropTarget(pasteBox, this); }
From source file:com.AandR.beans.plotting.LinePlotPanel.LinePlotPanel.java
public LinePlotPanel(int type) { if (type == SCATTER_PLOT) { isSymbolVisible = true;/* w ww. j a v a2 s . com*/ isLineVisible = false; } else { isSymbolVisible = false; isLineVisible = true; } initialize(); new DropTarget(this, plotPanelListener); setLayout(new BorderLayout()); add(centerSplitter, BorderLayout.CENTER); }