List of usage examples for javax.swing DropMode INSERT
DropMode INSERT
To view the source code for javax.swing DropMode INSERT.
Click Source Link
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
/** * Creates new form FAdmin/* w ww. java 2 s .com*/ */ public FAdmin() { addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { timer.stop(); } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { Uses.closeSplash(); } @Override public void windowDeactivated(WindowEvent e) { } }); initComponents(); setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF())); try { setIconImage( ImageIO.read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/admin.png"))); } catch (IOException ex) { System.err.println(ex); } // final Toolkit kit = Toolkit.getDefaultToolkit(); setLocation((Math.round(kit.getScreenSize().width - getWidth()) / 2), (Math.round(kit.getScreenSize().height - getHeight()) / 2)); // ? ? final JFrame fr = this; tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/admin.png", getLocaleMessage("tray.caption")); tray.addItem(getLocaleMessage("tray.caption"), (ActionEvent e) -> { setVisible(true); setState(JFrame.NORMAL); }); tray.addItem("-", (ActionEvent e) -> { }); tray.addItem(getLocaleMessage("tray.exit"), (ActionEvent e) -> { dispose(); System.exit(0); }); int ii = 1; final ButtonGroup bg = new ButtonGroup(); final String currLng = Locales.getInstance().getLangCurrName(); for (String lng : Locales.getInstance().getAvailableLocales()) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem( org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext() .getActionMap(FAdmin.class, fr).get("setCurrentLang")); bg.add(item); item.setSelected(lng.equals(currLng)); item.setText(lng); // NOI18N item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N menuLangs.add(item); } // ?? ??. listUsers.addListSelectionListener((ListSelectionEvent e) -> { userListChange(); }); // ?? ??. listResponse.addListSelectionListener((ListSelectionEvent e) -> { responseListChange(); }); listSchedule.addListSelectionListener((ListSelectionEvent e) -> { scheduleListChange(); }); listCalendar.addListSelectionListener(new ListSelectionListener() { private int oldSelectedValue = 0; private int tmp = 0; public int getOldSelectedValue() { return oldSelectedValue; } public void setOldSelectedValue(int oldSelectedValue) { this.oldSelectedValue = tmp; this.tmp = oldSelectedValue; } private boolean canceled = false; @Override public void valueChanged(ListSelectionEvent e) { if (canceled) { canceled = false; } else { if (tableCalendar.getModel() instanceof CalendarTableModel) { final CalendarTableModel model = (CalendarTableModel) tableCalendar.getModel(); if (!model.isSaved()) { final int res = JOptionPane.showConfirmDialog(null, getLocaleMessage("calendar.change.title"), getLocaleMessage("calendar.change.caption"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (res) { case 0: // ? ?? model.save(); calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); break; case 1: // ?? ?? calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); break; case 2: // ?? ??? canceled = true; listCalendar.setSelectedIndex(getOldSelectedValue()); break; } } else { calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); } } else { calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); } } } }); // ?? ? ??. treeServices.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); treeInfo.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); /* treeServices.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); setText(((Element) value).attributeValue(Uses.TAG_NAME)); return this; } });*/ treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> { serviceListChange(); }); treeInfo.addTreeSelectionListener((TreeSelectionEvent e) -> { infoListChange(); }); textFieldStartTime.setInputVerifier(DateVerifier); textFieldFinishTime.setInputVerifier(DateVerifier); // ? loadSettings(); // ? ?. startTimer(); // loadConfig(); spinnerPropServerPort.getModel().addChangeListener(new ChangeNet()); spinnerPropClientPort.getModel().addChangeListener(new ChangeNet()); spinnerWebServerPort.getModel().addChangeListener(new ChangeNet()); spinnerServerPort.getModel().addChangeListener(new ChangeSettings()); spinnerClientPort.getModel().addChangeListener(new ChangeSettings()); spinnerUserRS.getModel().addChangeListener(new ChangeUser()); //? . final Helper helper = Helper.getHelp("ru/apertum/qsystem/client/help/admin.hs"); helper.setHelpListener(menuItemHelp); helper.enableHelpKey(jPanel1, "introduction"); helper.enableHelpKey(jPanel3, "monitoring"); helper.enableHelpKey(jPanel4, "configuring"); helper.enableHelpKey(jPanel8, "net"); helper.enableHelpKey(jPanel17, "schedulers"); helper.enableHelpKey(jPanel19, "calendars"); helper.enableHelpKey(jPanel2, "infoSystem"); helper.enableHelpKey(jPanel13, "responses"); helper.enableHelpKey(jPanel18, "results"); treeServices.setTransferHandler(new TransferHandler() { @Override public boolean canImport(TransferHandler.TransferSupport info) { final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation(); if (dl.getChildIndex() == -1) { return false; } // Get the string that is being dropped. final Transferable t = info.getTransferable(); final QService data; try { data = (QService) t.getTransferData(DataFlavor.stringFlavor); return (data.getParent().getId() .equals(((QService) dl.getPath().getLastPathComponent()).getId())); } catch (UnsupportedFlavorException | IOException e) { return false; } } @Override public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; } final QService data; try { data = (QService) info.getTransferable().getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException | IOException e) { System.err.println(e); return false; } final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation(); final TreePath tp = dl.getPath(); final QService parent = (QService) tp.getLastPathComponent(); ((QServiceTree) treeServices.getModel()).moveNode(data, parent, dl.getChildIndex()); return true; } @Override public int getSourceActions(JComponent c) { return MOVE; } @Override protected Transferable createTransferable(JComponent c) { return (QService) ((JTree) c).getLastSelectedPathComponent(); } }); treeServices.setDropMode(DropMode.INSERT); // ? final AnnotationSessionFactoryBean as = (AnnotationSessionFactoryBean) Spring.getInstance().getFactory() .getBean("conf"); if (as.getServers().size() > 1) { final JMenu menu = new JMenu(getLocaleMessage("admin.servers")); as.getServers().stream().map((ser) -> { final JMenuItem mi1 = new JMenuItem(as); mi1.setText(ser.isCurrent() ? "<html><u><i>" + ser.getName() + "</i></u>" : ser.getName()); return mi1; }).forEach((mi1) -> { menu.add(mi1); }); jMenuBar1.add(menu, 4); jMenuBar1.add(new JLabel( "<html><span style='font-size:13.0pt;color:red'> [" + as.getName() + "]")); } comboBoxVoices.setVisible(false); }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
/** * panel initialization/*w w w . j av a 2s . co m*/ */ private void init() { setLayout(new GridBagLayout()); thumbnailList.setDrawDeletedItems(drawDeletedItems); if (dndSupport == DND_SUPPORT_FILES) { thumbnailList.setTransferHandler(new VisualListExportTransferHandler(pdfLoader)); } else if (dndSupport == DND_SUPPORT_JAVAOBJECTS) { thumbnailList.setTransferHandler(new VisualListTransferHandler()); } else if (dndSupport == DND_SUPPORT_FILES_AND_JAVAOBJECTS) { thumbnailList.setTransferHandler(new VisualListTransferHandler(pdfLoader)); } else { thumbnailList.setTransferHandler(new VisualListExportTransferHandler(null)); } thumbnailList.setDragEnabled(true); thumbnailList.setDropMode(DropMode.INSERT); pagesWorker = new PagesWorker(thumbnailList); thumbnailList.addKeyListener(new VisualPdfSelectionKeyAdapter(pagesWorker)); thumbnailList.addMouseListener(new PageOpenerMouseAdapter(thumbnailList)); if (showButtonPanel) { initButtonPanel(pagesWorker); initKeyListener(); } //JList orientation if (HORIZONTAL_ORIENTATION == orientation) { thumbnailList.setLayoutOrientation(JList.HORIZONTAL_WRAP); } else { if (wrap) { thumbnailList.setLayoutOrientation(JList.VERTICAL_WRAP); } } topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.setPreferredSize(new Dimension(400, 30)); pdfSelectionActionListener = new VisualPdfSelectionActionListener(this, pdfLoader); if (topPanelStyle >= STYLE_TOP_PANEL_FULL) { //load button loadFileButton.setMargin(new Insets(1, 1, 1, 1)); loadFileButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Open")); loadFileButton.setPreferredSize(new Dimension(100, 30)); loadFileButton .setToolTipText(GettextResource.gettext(config.getI18nResourceBundle(), "Load a pdf document")); loadFileButton.setIcon(new ImageIcon(this.getClass().getResource("/images/add.png"))); loadFileButton.addKeyListener(new EnterDoClickListener(loadFileButton)); loadFileButton.setAlignmentX(Component.CENTER_ALIGNMENT); loadFileButton.setAlignmentY(Component.CENTER_ALIGNMENT); loadFileButton.setActionCommand(VisualPdfSelectionActionListener.ADD); loadFileButton.addActionListener(pdfSelectionActionListener); } documentProperties.setIcon(new ImageIcon(this.getClass().getResource("/images/info.png"))); documentProperties.setVisible(false); if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) { clearButton.setMargin(new Insets(1, 1, 1, 1)); clearButton.setMinimumSize(new Dimension(30, 30)); clearButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Clear")); clearButton.setIcon(new ImageIcon(this.getClass().getResource("/images/clear.png"))); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetPanel(); } }); } zoomInButton.setMargin(new Insets(1, 1, 1, 1)); zoomInButton.setMinimumSize(new Dimension(30, 30)); zoomInButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom in")); zoomInButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomin.png"))); zoomInButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { thumbnailList.incZoomLevel(); zoomOutButton.setEnabled(true); if (thumbnailList.getCurrentZoomLevel() >= JVisualSelectionList.MAX_ZOOM_LEVEL) { zoomInButton.setEnabled(false); } ((VisualListModel) thumbnailList.getModel()).elementsChanged(); } catch (Exception ex) { log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."), ex); } } }); zoomOutButton.setMargin(new Insets(1, 1, 1, 1)); zoomOutButton.setMinimumSize(new Dimension(30, 30)); zoomOutButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom out")); zoomOutButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomout.png"))); zoomOutButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { thumbnailList.deincZoomLevel(); zoomInButton.setEnabled(true); if (thumbnailList.getCurrentZoomLevel() <= JVisualSelectionList.MIN_ZOOM_LEVEL) { zoomOutButton.setEnabled(false); } ((VisualListModel) thumbnailList.getModel()).elementsChanged(); } catch (Exception ex) { log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."), ex); } } }); thumbnailList.setModel(new VisualListModel()); thumbnailList.setCellRenderer(new VisualListRenderer()); thumbnailList.setVisibleRowCount(-1); thumbnailList.setSelectionMode(selectionType); JScrollPane listScroller = new JScrollPane(thumbnailList); //preview item menuItemPreview.setIcon(new ImageIcon(this.getClass().getResource("/images/preview-viewer.png"))); menuItemPreview.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Preview")); menuItemPreview.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { int[] selection = thumbnailList.getSelectedIndices(); if (selection != null && selection.length == 1) { VisualPageListItem item = (VisualPageListItem) thumbnailList.getModel() .getElementAt(selection[0]); PagePreviewOpener.getInstance().openPreview(item.getParentFileCanonicalPath(), item.getDocumentPassword(), item.getPageNumber()); } } }); if (showContextMenu) { //popup final JMenuItem menuItemMoveUp = new JMenuItem(); menuItemMoveUp.setIcon(new ImageIcon(this.getClass().getResource("/images/up.png"))); menuItemMoveUp.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Up")); menuItemMoveUp.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_UP, pagesWorker)); popupMenu.add(menuItemMoveUp); final JMenuItem menuItemMoveDown = new JMenuItem(); menuItemMoveDown.setIcon(new ImageIcon(this.getClass().getResource("/images/down.png"))); menuItemMoveDown.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Down")); menuItemMoveDown .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_DOWN, pagesWorker)); popupMenu.add(menuItemMoveDown); final JMenuItem menuItemRemove = new JMenuItem(); menuItemRemove.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png"))); menuItemRemove.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Delete")); menuItemRemove.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REMOVE, pagesWorker)); popupMenu.add(menuItemRemove); //if elements are physically deleted i don't need this item if (drawDeletedItems) { final JMenuItem menuItemUndelete = new JMenuItem(); menuItemUndelete.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png"))); menuItemUndelete.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Undelete")); menuItemUndelete .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.UNDELETE, pagesWorker)); popupMenu.add(menuItemUndelete); } //rotate item final JMenuItem menuItemRotate = new JMenuItem(); menuItemRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/clockwise.png"))); menuItemRotate.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate clockwise")); menuItemRotate .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_CLOCK, pagesWorker)); popupMenu.add(menuItemRotate); //rotate anticlock item final JMenuItem menuItemAntiRotate = new JMenuItem(); menuItemAntiRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/anticlockwise.png"))); menuItemAntiRotate .setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate anticlockwise")); menuItemAntiRotate.addMouseListener( new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_ANTICLOCK, pagesWorker)); popupMenu.add(menuItemAntiRotate); //reverse item final JMenuItem menuItemReverse = new JMenuItem(); menuItemReverse.setIcon(new ImageIcon(this.getClass().getResource("/images/reverse.png"))); menuItemReverse.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Reverse")); menuItemReverse.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REVERSE, pagesWorker)); popupMenu.add(menuItemReverse); enableSetOutputPathMenuItem(); addPopupShower(); } popupMenu.add(menuItemPreview); if (topPanelStyle >= STYLE_TOP_PANEL_FULL) { topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(loadFileButton); } if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) { topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(clearButton); } topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(documentProperties); topPanel.add(Box.createHorizontalGlue()); topPanel.add(zoomInButton); topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(zoomOutButton); GridBagConstraints topConstraints = new GridBagConstraints(); topConstraints.fill = GridBagConstraints.BOTH; topConstraints.gridx = 0; topConstraints.gridy = 0; topConstraints.gridwidth = 3; topConstraints.gridheight = 1; topConstraints.insets = new Insets(5, 5, 5, 5); topConstraints.weightx = 1.0; topConstraints.weighty = 0.0; if (topPanelStyle > STYLE_TOP_PANEL_HIDE) { add(topPanel, topConstraints); } GridBagConstraints thumbConstraints = new GridBagConstraints(); thumbConstraints.fill = GridBagConstraints.BOTH; thumbConstraints.gridx = 0; thumbConstraints.gridy = 1; thumbConstraints.gridwidth = (showButtonPanel ? 2 : 3); thumbConstraints.gridheight = 2; thumbConstraints.insets = new Insets(5, 5, 5, 5); thumbConstraints.weightx = 1.0; thumbConstraints.weighty = 1.0; add(listScroller, thumbConstraints); if (showButtonPanel) { GridBagConstraints buttonsConstraints = new GridBagConstraints(); buttonsConstraints.fill = GridBagConstraints.BOTH; buttonsConstraints.gridx = 2; buttonsConstraints.gridy = 1; buttonsConstraints.gridwidth = 1; buttonsConstraints.gridheight = 2; buttonsConstraints.insets = new Insets(5, 5, 5, 5); buttonsConstraints.weightx = 0.0; buttonsConstraints.weighty = 1.0; add(buttonPanel, buttonsConstraints); } }
From source file:org.rimudb.editor.DescriptorEditor.java
/** * Build the panel//from ww w .j ava 2s.c o m */ private JPanel createColumnTablePanel() { JPanel columnPanel = new JPanel(); columnPanel.setLayout(new BoxLayout(columnPanel, BoxLayout.Y_AXIS)); // Create the property table panel propertyModel = new PropertyTableModel(); // Add a listener to set the changed state propertyModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { markChanged(); if (e instanceof PropertyTableModelEvent) { PropertyTableModelEvent ptme = (PropertyTableModelEvent) e; // If the columnName column was changed then check it isn't // a PK if (ptme.getColumn() == 1) { String beforeColumnName = (String) ptme.getBeforeValue(); String afterColumnName = (String) ptme.getAfterValue(); // Is the field entry in the list of primary keys? for (int i = 0; i < pkListModel.getSize(); i++) { String pkColumnName = (String) pkListModel.get(i); // If it's found then remove it if (beforeColumnName.equals(pkColumnName)) { pkListModel.set(i, afterColumnName); break; } } } } } }); table = new ATable(getPropertyModel()); table.setName("ColumnTable"); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRowCount = table.getSelectedRowCount(); removeColumnBtn.setEnabled(selectedRowCount > 0); moveUpBtn.setEnabled(selectedRowCount > 0); moveDownBtn.setEnabled(selectedRowCount > 0); } }); table.setTransferHandler(new TransferHandler() { public int getSourceActions(JComponent c) { return COPY; } protected Transferable createTransferable(JComponent c) { ATable columnTable = (ATable) c; int row = columnTable.getSelectedRow(); String columnName = getPropertyModel().getRow(row).getColumnName(); return new StringSelection(columnName); } }); table.setDragEnabled(true); JScrollPane sp = new JScrollPane(table); sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 325)); sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 325)); sp.setMinimumSize(new Dimension(Short.MAX_VALUE, 325)); JComboBox typeCB = new JComboBox(DatabaseTypes.getAllTypes()); typeCB.setEditable(false); javax.swing.table.TableColumn typeColumn = table.getColumnModel().getColumn(2); typeColumn.setCellEditor(new DefaultCellEditor(typeCB)); // Create the popup menu and set it on the table propertyPopup = new TablePopupMenu(this, table); table.addMouseListener(propertyPopup); sp.addMouseListener(propertyPopup); sp.setAlignmentX(LEFT_ALIGNMENT); columnPanel.add(sp); columnPanel.add(Box.createVerticalStrut(10)); JLabel pkLabel = new JLabel("Primary Key Columns", SwingConstants.LEFT); pkLabel.setAlignmentX(LEFT_ALIGNMENT); columnPanel.add(pkLabel); pkListModel = new DefaultListModel(); pkListModel.addListDataListener(new ListDataListener() { public void intervalRemoved(ListDataEvent e) { markChanged(); } public void intervalAdded(ListDataEvent e) { markChanged(); } public void contentsChanged(ListDataEvent e) { markChanged(); } }); pkList = new JList(pkListModel); pkList.setName("pkList"); pkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); pkList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRowCount = pkList.getSelectedIndex(); removePkBtn.setEnabled(selectedRowCount > -1); } }); pkList.setTransferHandler(new TransferHandler() { public boolean canImport(TransferHandler.TransferSupport info) { // we only import Strings if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); if (dl.getIndex() == -1) { return false; } return true; } public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; } // Check for String flavor if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { displayDropLocation("List doesn't accept a drop of this type."); return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); DefaultListModel listModel = (DefaultListModel) pkList.getModel(); int index = dl.getIndex(); // Get the string that is being dropped. Transferable t = info.getTransferable(); String data; try { data = (String) t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { return false; } // If this is a copy action then check we don't already have that String if (info.getDropAction() == COPY && listModel.indexOf(data) > -1) { displayDropLocation("The column " + data + " is already a primary key"); return false; } // Perform the actual import. if (dl.isInsert()) { int oldIndex = listModel.indexOf(data); if (oldIndex < index) { listModel.add(index, data); listModel.remove(oldIndex); } else { listModel.remove(oldIndex); listModel.add(index, data); } } else { // Don't handle replacements } return true; } public int getSourceActions(JComponent c) { return MOVE; } protected Transferable createTransferable(JComponent c) { JList list = (JList) c; Object[] values = list.getSelectedValues(); StringBuffer buff = new StringBuffer(); for (int i = 0; i < values.length; i++) { Object val = values[i]; buff.append(val == null ? "" : val.toString()); if (i != values.length - 1) { buff.append("\n"); } } return new StringSelection(buff.toString()); } }); pkList.setDropMode(DropMode.INSERT); pkList.setDragEnabled(true); JScrollPane pkScrollPanel = new JScrollPane(pkList); pkScrollPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 100)); pkScrollPanel.setAlignmentX(LEFT_ALIGNMENT); columnPanel.add(pkScrollPanel); return columnPanel; }