javax.swing.DropMode Java Examples

The following examples show how to use javax.swing.DropMode. 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: PvExplorer.java    From AndrOBD with GNU General Public License v3.0 6 votes vote down vote up
public PvExplorer(ProcessVar pv)
{
	setDividerSize(2);
	setPreferredSize(new Dimension(640, 480));

	pvTree = new JTree(new PvTreeNode(pv));
	pvTree.getSelectionModel().addTreeSelectionListener(this);
	pvTree.setDragEnabled(true);
	pvTree.setDropMode(DropMode.ON_OR_INSERT);
	pvTree.setTransferHandler(xferHdlr);

	pvTable = new PvTable(pv);
	pvTable.setDragEnabled(true);
	pvTable.setDropMode(DropMode.ON_OR_INSERT);
	pvTable.addMouseListener(tblMouseLstnr);
	pvTable.setTransferHandler(xferHdlr);

	JScrollPane spPvTree = new JScrollPane(pvTree);
	add(spPvTree, JSplitPane.LEFT);
	JScrollPane spPvTable = new JScrollPane(pvTable);
	add(spPvTable, JSplitPane.RIGHT);
}
 
Example #2
Source File: PlotConfigurationTree.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public PlotConfigurationTree(PlotConfiguration plotConfiguration, DataTable dataTable,
		DataTableColumnListTransferHandler aTH) {
	super();
	expandAll();

	// forces the tree to ask the nodes for the correct row heights
	// must also be invoked after LaF changes...
	setRowHeight(0);

	getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	setExpandsSelectedPaths(true);

	// DnD support
	setDragEnabled(true);
	setDropMode(DropMode.INSERT);

	// Rendering
	setShowsRootHandles(false);
	setBackground(Colors.WHITE);
	setCellRenderer(new PlotConfigurationTreeCellRenderer(aTH));
	putClientProperty("JTree.lineStyle", "Horizontal");

	createNewTreeModel(plotConfiguration);
}
 
Example #3
Source File: TypesTree.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public TypesTree() {
  setRootVisible(false);
  setDragEnabled(true);
  setDropMode(DropMode.INSERT); // Dropped objects are inserted behind the drop location.
  setToggleClickCount(1); // Child nodes expand with a single click.
  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  setSelectionModel(selectionModel);
  final IconNodeRenderer renderer = new IconNodeRenderer();
  renderer.setFont(GuiHelper.MONOSPACED_FONT);
  setCellRenderer(renderer);
}
 
Example #4
Source File: LayerManagerForm.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private CheckBoxTree createCheckBoxTree(LayerTreeModel treeModel) {

        final CheckBoxTree checkBoxTree = new CheckBoxTree(treeModel) {
            @Override
            public boolean isPathEditable(TreePath path) {
                Layer layer = getLayer(path);
                if (layer != null) {
                    return isLayerNameEditable(layer);
                }
                return false;
            }  
        };
        checkBoxTree.setRootVisible(false);
        checkBoxTree.setShowsRootHandles(true);
        checkBoxTree.setDigIn(false);

        checkBoxTree.setEditable(true);
        checkBoxTree.setDragEnabled(true);
        checkBoxTree.setDropMode(DropMode.ON_OR_INSERT);
        checkBoxTree.setTransferHandler(new LayerTreeTransferHandler(view, checkBoxTree));

        checkBoxTree.getSelectionModel().addTreeSelectionListener(new LayerSelectionListener());

        final CheckBoxTreeSelectionModel checkBoxSelectionModel = checkBoxTree.getCheckBoxTreeSelectionModel();
        checkBoxSelectionModel.addTreeSelectionListener(new CheckBoxTreeSelectionListener());

        final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
        renderer.setLeafIcon(null);
        renderer.setClosedIcon(null);
        renderer.setOpenIcon(null);
        return checkBoxTree;
    }
 
Example #5
Source File: PurchaseInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void install()
{
	availableTable.setDragEnabled(true);
	availableTable.setDropMode(DropMode.ON);
	availableTable.setTransferHandler(this);

	purchasedTable.setDragEnabled(true);
	purchasedTable.setDropMode(DropMode.ON);
	purchasedTable.setTransferHandler(this);
}
 
Example #6
Source File: ProjectTree.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 */
public ProjectTree() {

  ProjectTreeRenderer renderer = new ProjectTreeRenderer();
  setCellRenderer(renderer);

  DefaultTreeCellEditor editor =
      new DefaultTreeCellEditor(this, renderer, new ProjectTreeEditor(this));
  setCellEditor(editor);
  setEditable(true);
  setInvokesStopCellEditing(true);

  setRootVisible(true);
  setShowsRootHandles(false);

  setToggleClickCount(-1);

  // Activate drag&drop
  ProjectTreeDnDHandler dndHandler = new ProjectTreeDnDHandler();
  setTransferHandler(dndHandler);
  setDropMode(DropMode.INSERT);
  setDragEnabled(true);

  // Attach a handler for handling popup menus and double clicks
  ProjectTreeMouseHandler popupHandler = new ProjectTreeMouseHandler(this);
  addMouseListener(popupHandler);

}
 
Example #7
Source File: PurchaseInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void install()
{
	availableTable.setDragEnabled(true);
	availableTable.setDropMode(DropMode.ON);
	availableTable.setTransferHandler(this);

	purchasedTable.setDragEnabled(true);
	purchasedTable.setDropMode(DropMode.ON);
	purchasedTable.setTransferHandler(this);
}
 
Example #8
Source File: DragDropList.java    From constellation with Apache License 2.0 5 votes vote down vote up
DragDropList() {
        setDragEnabled(true);
        setDropMode(DropMode.INSERT);
        setTransferHandler(new MyListDropHandler(this));
        new MyDragListener(this);

        model = new MyListModel(new String[0]);
//        setSelectedLayers(visibleLayers);
    }
 
Example #9
Source File: LastNodeLowerHalfDrop.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private JScrollPane getContent() {
    jTree = new JTree(getTreeModel());
    jTree.setRootVisible(false);
    jTree.setDragEnabled(true);
    jTree.setDropMode(DropMode.INSERT);
    jTree.setTransferHandler(new TreeTransferHandler());
    jTree.getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
    expandTree(jTree);
    return new JScrollPane(jTree);
}
 
Example #10
Source File: FolderList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new form FolderList */
public FolderList (String label, char mnemonic, String accessibleDesc, String fcMessage,
                   char addButtonMnemonic, String addButtonAccessibleDesc,
                   char removeButtonMnemonic,String removeButtonAccessibleDesc) {
    this.fcMessage = fcMessage;
    initComponents();
    this.jLabel1.setText(label);
    this.jLabel1.setDisplayedMnemonic(mnemonic);
    this.roots.getAccessibleContext().setAccessibleName(accessibleDesc);
    this.roots.setCellRenderer(new Renderer());
    this.roots.setModel (new DefaultListModel());
    this.roots.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                removeButton.setEnabled(roots.getSelectedIndices().length != 0);
            }
        }
    });
    this.roots.setDragEnabled(true);
    this.roots.setDropMode(DropMode.INSERT);
    this.roots.setTransferHandler(new DNDHandle());
    this.addButton.getAccessibleContext().setAccessibleDescription(addButtonAccessibleDesc);
    this.addButton.setMnemonic (addButtonMnemonic);        
    this.removeButton.getAccessibleContext().setAccessibleDescription(removeButtonAccessibleDesc);
    this.removeButton.setMnemonic (removeButtonMnemonic);
    this.removeButton.setEnabled(false);
}
 
Example #11
Source File: DropDemo.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ae) {
    Object val = dropCombo.getSelectedItem();
    if (val == "USE_SELECTION") {
        list.setDropMode(DropMode.USE_SELECTION);
    } else if (val == "ON") {
        list.setDropMode(DropMode.ON);
    } else if (val == "INSERT") {
        list.setDropMode(DropMode.INSERT);
    } else if (val == "ON_OR_INSERT") {
        list.setDropMode(DropMode.ON_OR_INSERT);
    }
}
 
Example #12
Source File: JListXTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
                @Override
                public void eventDispatched(AWTEvent event) {
                }
            }, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
            frame = new JFrame("My Dialog");
            frame.setName("dialog-1");
            Object[] listData = new Object[30];
            for (int i = 1; i <= listData.length; i++) {
                if (i == 25) {
                    listData[i - 1] = "List Item - '" + i + "'";
                } else {
                    listData[i - 1] = "List Item - " + i;
                }
            }
            list = new JList(listData);
            list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            list.setName("list-1");
            list.setDragEnabled(true);
            JPanel p = new JPanel(new BorderLayout());
            p.add(new JScrollPane(list), BorderLayout.NORTH);
            textfield = new JTextField(80);
            textfield.setName("text-field");
            textfield.setDropMode(DropMode.USE_SELECTION);
            p.add(textfield, BorderLayout.SOUTH);
            frame.getContentPane().add(p);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
            list.requestFocusInWindow();
        }
    });
}
 
Example #13
Source File: FileDropTransferHandler.java    From Ultraino with MIT License 4 votes vote down vote up
public static void addDroper(JTextField field){
    field.setDragEnabled(true);
    field.setDropMode(DropMode.INSERT);
    field.setTransferHandler( new FileDropTransferHandler() );
}
 
Example #14
Source File: EquipInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void install()
{
	equipmentTable.setDragEnabled(true);
	equipmentTable.setDropMode(DropMode.ON);
	equipmentTable.setTransferHandler(this);
}
 
Example #15
Source File: EquipInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void install()
{
	equipmentSetTable.setTransferHandler(this);
	equipmentSetTable.setDragEnabled(true);
	equipmentSetTable.setDropMode(DropMode.ON_OR_INSERT_ROWS);
}
 
Example #16
Source File: RowTreeTableComponent.java    From ramus with GNU General Public License v3.0 4 votes vote down vote up
public RowTreeTableComponent(Engine engine, Qualifier qualifier,
                             AccessRules accessRules, RootCreater rootCreater,
                             Attribute[] attributes, GUIFramework framework) {
    super(new BorderLayout());

    AttributePlugin[] plugins = new AttributePlugin[attributes.length];

    for (int i = 0; i < attributes.length; i++) {
        AttributePlugin plugin = framework
                .findAttributePlugin(attributes[i]);
        if (plugin == null) {
            System.err.println("WARNING: GUI Plugin for attribute type: "
                    + attributes[i].getAttributeType() + " not found");
        } else {
            plugins[i] = plugin;
        }
    }

    model = createRowTreeTableModel(engine, qualifier, accessRules,
            rootCreater, attributes, framework);

    if (qualifier.equals(StandardAttributesPlugin
            .getAttributesQualifier(engine))) {
        model.setAttributeLocalizer(
                new RowTreeTableModel.Localizer() {
                    @Override
                    public Object getValue(Object key) {
                        return GlobalResourcesManager
                                .getString("AttributeType." + key);
                    }
                }, (Attribute) engine.getPluginProperty("Core",
                        StandardAttributesPlugin.ATTRIBUTE_TYPE_NAME));

    }

    table = createTable(accessRules, framework, plugins);
    model.setTable(table);
    this.rowSet = model.getRowSet();
    table.setDropMode(DropMode.ON_OR_INSERT_ROWS);
    table.setTransferHandler(new RowTransferHandle());

    header = new TableRowHeader(table, model);

    boolean dragEnable = true;
    // Fixing dragging of IDEF0 and DFD functions
    for (Attribute attr : qualifier.getSystemAttributes()) {
        if (attr.getAttributeType().getTypeName().equals("VisualData"))
            dragEnable = false;
    }

    header.setDragEnabled(dragEnable);
    header.setTransferHandler(new RowTransferHandle());
    header.setDropMode(DropMode.INSERT);

    pane.setViewportView(table);
    pane.setRowHeaderView(header);
    this.add(pane, BorderLayout.CENTER);
    findPanel.setVisible(false);
    this.add(findPanel, BorderLayout.SOUTH);

    table.getInputMap().put(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK),
            "showFindPanel");

    table.getActionMap().put("showFindPanel", new AbstractAction() {
        /**
         *
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent e) {
            if (!findPanel.isVisible()) {
                findPanel.setVisible(true);
            }
            findPanel.getJTextField().requestFocus();
        }

    });

    ScrollPanePreview.install(pane);
}
 
Example #17
Source File: TableEditor.java    From ramus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public JComponent getComponent() {
    pane = new JScrollPane();
    pane.setViewportView(editorTable);

    header = new TableHeader(editorTable, model);

    header.setDragEnabled(true);
    header.setTransferHandler(new RowTransferHandle());
    header.setDropMode(DropMode.INSERT);

    pane.setRowHeaderView(header);


    editorTable.setDropMode(DropMode.INSERT_ROWS);
    editorTable.setTransferHandler(new RowTransferHandle());

    return pane;
}
 
Example #18
Source File: EquipInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void install()
{
	equipmentTable.setDragEnabled(true);
	equipmentTable.setDropMode(DropMode.ON);
	equipmentTable.setTransferHandler(this);
}
 
Example #19
Source File: EquipInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void install()
{
	equipmentSetTable.setTransferHandler(this);
	equipmentSetTable.setDragEnabled(true);
	equipmentSetTable.setDropMode(DropMode.ON_OR_INSERT_ROWS);
}