Restricted DND among JLists

I have an applet with four JLists. I need to move items between the lists, but items from some lists are not allowed on other lists. Essentially, I need to know when an item is dragged/dropped on a list, what type of object it is so I can determine if this is allowed. If it is allowed, move the item. If it is not allowed, visually display to the user somehow (mouse icon or message box) that this is not allowed and keep the item on its original list. I'm open to any solution that will allow this to occur.
More details:
The items in the lists are custom objects called Medication.There are two types of Medication objects: Home and Visit. Both are the instances of the same object (Medication) with different values for the variable "type".
Home medications are initially members of HomeJList.
Visit medications are initially members of VisitJList.
There are two other Jlists in the application: DiscontinueJList and ContinueJList. This is the only navigation allowed:
<ul><li>DiscontinueJList can accept Home medications. </li>
<li>HomeJList can accept Home medications. </li>
<li>VisitJList can accept Visit medications. </li>
<li>ContinueJList can accept Home and Visit medications.</li>
</ul>
I have created three different TransferHandler objects, as well as my own Transferable with its own DataFlavor.
<ul><li>DiscontinueJList and HomeJList use HomeListTransferHandler to only accept Home medications. </li>
<li>VisitJList use VisitListTransferHandler to only accept Visit medications. </li>
<li>ContinueJList use ListTransferHandler to accept Home and Visit medications.
</li>
</ul>
Questions:
1) In the TransferHandler, I can identify an object as one that shouldn't be dropped. I display a message that this type of object is not allowed in this list. However, the sending list's TransferHandler has no way to know that this behavior is prohibited, and the selected item is removed in exportDone. Thus the item that wasn't allowed to be moved to the selected list is removed from its existing list. I don't know of a way to notify the sending list's TransferHandler that the move was rejected. Is this possible?
2) As an alternate, I have pursued attaching a DropTargetListener to each list. I have implemented dragOver to identify which list it is being dragged over. This works, but it only identifies the list that is being dragged over, not the source where the drag began.
I'd be happy to provide my code so far if it would help.
Any ideas are greatly appreciated. Thanks in advance.

My problem is that the source list doesn't know that the target rejected the drop; it assumes the drop was successful and removes the item from the source listI always assumed this was controlled by the canImport(...) method of the TransferHandler.
I tested using the ExtendedDnDemo from the older Swing tutorial. (I don't know if it has been updated for JDK6).
Anyway, using the code from the demo I tried dragging text from the text field to the JList and it worked. I then overrode the canImport(...) method of the StringTransferHandler to alway return false. This worked. The icon was always a reject icon and the text was never deleted from the source text field.

Similar Messages

  • Drag and Drop items among JList

    Hi,
    I want to drag item from one JList and drop into another JList using JFrame in java Swing. Please provide me code for this.
    Thanks
    Nitin

    You need to implement a drag-and-drop (dnd) behaviour between your swing components.
    Like most programming tasks it looks harder than it really is. Basically you need a DragSource and a DropTarget with a Transferable object in between. This Transferable object is the object from your list.
    Here is Sun's tutorial on it... http://java.sun.com/docs/books/tutorial/dnd/
    Good luck.

  • DnD from JList into JTree

    Can anyone point me at a tutorial demonstarting how to drag objects from a JList into a JTree?
    many thanks

    Let me add some more information to maybe get some suggestions:
    I have DnD implemented in my tree - as my nodes are DefaultMutableTreeNode it is easy to getUserObject() and carry out the necessary changes to model and underlying object.
    In my JList(x2) I have custom objects, DnD is implemented on each list. My question is how should I wrap my JList objects so that I can retrieve the user object when I drop it into my tree?
    I have found an example of dragging nodes from one tree to another tree, but this is of little help as the DnD is simply dragging the String object about.
    Any pointers/suggestions please

  • DnD between Jlist and Canvas...

    Is it all possible to drag the list item from JList and drop it inside the Canvas and place a reference (e.g. lsit item name ) at the exact coordinates where the drop is performed?
    Additionally, for the purpose of my project the Canvas already contains an image of a model space and would need to stay in the background all along!
    Please if anyone have any thoughts, recomendations, suggestions post these here.
    Thanks

    Please, is drag and drop possible between JList and Canvas components so that the inserted item from JList is displayed over the image displayed in the Canvas component?

  • How We can restrict the max no of Selections in JList

    Hi,
    How We can restrict the max. no of selections (at random selections) in JList (ex. max No of of selections is 3 in a JList of having 50 items.)
    Thanks for your advise in advance.

    Hello Satyaki De.
    Thank you very much for your suggestion but my Private information is totally apart from this question & I already I have changed each and every information from the question.
    Thanks
    Kamlesh Gujarathi
    [email protected]

  • Error :Value of restricted LOV parameter not among the selectable values

    Hi,
    I am designing a report which has two layouts. I have a parameter :P_Reason_code which is applicable to only one layout.
    There is a repeating frame in my first layout which should display only if :P_Reason_code value is 'Y'.
    I have wriiten a format trigger for this repeating frame saying the repating frame should return true if :P_Reason_code value= 'Y'.
    else, it should return false meaning it shouldnt display.
    :P_Reason_code is an optional parameter when i run it at the oracle apps front end.
    The problem that i am facing is that when i run the report for the second layout by not providing value for the parameter :P_Reason_code
    , it errors out saying "REP-0788: Warning: The value of restricted LOV parameter P_REASON_CODE is not among the selectable values.'
    I tried creating another user parameter P_REASON_CODE1 and putting a trigger in the After parameter form trigger saying
    if P_REASON_CODE is null then
    P_REASON_CODE1 :='Y';
    P_REASON_CODE := P_REASON_CODE1;
    ELSE
    P_REASON_CODE1 := P_REASON_CODE;
    P_REASON_CODE := P_REASON_CODE;
    END IF;
    But still it doesnt seem to work.
    What could be the issue?
    Can anyone help?

    try setting the default-value for the parameter to Y (or whatever value is in the LoV defined for the parameter).
    Is there a parameterform used for the report. If not remove the LoV from the parameter.

  • DND from a JList with a single gesture

    I am writing an application that allows users to drag an item from a JList in one JInternalFrame to a JList in another. The users are complaining that "sometimes it works and sometimes it doesn't". I'm using JDK 1.4.2_02.
    As an example of the required behavior, imagine using the Windows Explorer to move a file from one directory to another. You do not have to click once on a file name to select it and click again to start the drag operation; you just click once and start dragging, whether the file was "selected" or not.
    However, when you try to drag from a JList, the gesture works only if the item you click on is already selected. Otherwise you have to click once on the item to select it and click again to start dragging. For most applications (for instance a word processor) you would expect this behavior, but for this application it is confusing and unacceptable. You feel like you're using a vaccuum cleaner that doesn't always pick up the dirt.
    The reason for the behavior can be found in the platform-dependent Swing code, in either com/sun/java/swing/plaf/gtk/SynthListUI.java or javax/swing/plaf/basic/BasicTextUI.java:
        private static final ListDragGestureRecognizer defaultDragRecognizer = new ListDragGestureRecognizer();
         * Drag gesture recognizer for JList components
        static class ListDragGestureRecognizer extends BasicDragGestureRecognizer {
          * Determines if the following are true:
          * <ul>
          * <li>the press event is located over a selection
          * <li>the dragEnabled property is true
          * <li>A TranferHandler is installed
          * </ul>
          * <p>
          * This is implemented to perform the superclass behavior
          * followed by a check if the dragEnabled
          * property is set and if the location picked is selected.
            protected boolean isDragPossible(MouseEvent e) {
             if (super.isDragPossible(e)) {
              JList list = (JList) this.getComponent(e);
              if (list.getDragEnabled()) {
                  ListUI ui = list.getUI();
                  int row = ui.locationToIndex(list, new Point(e.getX(),e.getY()));
                  if ((row != -1) && list.isSelectedIndex(row)) {
                   return true;
             return false;
        }Note that the method returns true only if the row is already selected.
    How can I fix this? The obvious method is to substitute my own version of ListDragGestureRecognizer, but that's an unsafe hack. BasicDragGestureRecognizer is not available to the application programmer and is potentially different for every platform and for different versions of the JVM. It's not "documented" that I know of, so there's no way to guarantee my own version is compatible.
    Mark Lutton

    First, see http://developer.java.sun.com/developer/bugParade/bugs/4521075.html
    There are two approaches there that worked for me: simon's and scmorr's. I prefer Simon's, but here is the code for both:
    1) based on scmorr's comments:
       private void fixListMouseListeners()
          MouseListener[] allMouseListeners = getMouseListeners();
          String listenerName = "javax.swing.plaf.basic.BasicListUI$ListDragGestureRecognizer";
          MouseListener listDragGestureRecognizer = null;
          // find the drag gesture listener we are looking for and remove it from
          // mouse listeners
          for (int i = 0; i < allMouseListeners.length; ++i)
             MouseListener currentListener = allMouseListeners[ i ];
             String currentListenerClassName = currentListener.getClass().getName();
             if (currentListenerClassName.equals(listenerName))
                listDragGestureRecognizer = currentListener;
                removeMouseListener(listDragGestureRecognizer);
                break;
          // add drag gesture listener back in at the end -- this allows the
          // mouse input handler (which does selection) to run first
          if (listDragGestureRecognizer != null)
             addMouseListener(listDragGestureRecognizer);
       }  // fixListMouseListeners()2) simon's approach:
       // the cached selection event
       private MouseEvent myCachedEvent;
        * overriding this so we can select and drag at same time
        * @param firstIndex is first interval index
        * @param lastIndex is last interval index
        * @param isAdjusting is whether event is an adjusting event
       protected void fireSelectionValueChanged(int firstIndex,
                                                int lastIndex,
                                                boolean isAdjusting)
          // now continue with update of whoever is listening to list for selection changes
          super.fireSelectionValueChanged(firstIndex, lastIndex, isAdjusting);
          // if the selection occurred and we have cached the event,
          // launch a copy of the cached event so dragging can occur right
          // away, if necessary
          if (myCachedEvent != null)
             super.processMouseEvent(new MouseEvent(               
                   (Component) myCachedEvent.getSource(),
                   myCachedEvent.getID(),     
                   myCachedEvent.getWhen(),     
                   myCachedEvent.getModifiersEx(),     
                   myCachedEvent.getX(),     
                   myCachedEvent.getY(),     
                   myCachedEvent.getClickCount(),     
                   myCachedEvent.isPopupTrigger()));
             myCachedEvent= null;
       }  // fireSelectionValueChanged()
        * overriding so we can cache the mouse event
        * @param e is the invoking event
       protected void processMouseEvent(MouseEvent e)
          int modifiers = e.getModifiersEx();
          // if clicked with left button, cache the event
          if ((modifiers & e.BUTTON1_DOWN_MASK) != 0)
             myCachedEvent = e;
          // go ahead and do normal processing on event
          super.processMouseEvent(e);
       }  // processMouseEvent()This does the job, but I had further requirements that required a bit more intervention. I am working with dragging an item between 2 JLists (single selection mode), and I am also trying to enforce that only one of my 2 lists can have a selection at any given time, using a ListSelectionListener, paying attention to events only if getValueIsAdjusting() is true.
    The problem comes if you abort a drag and then select an item in the other list that you weren't dragging from. When you drag, the list you drag from doesn't get a setValueIsAdjusting(false) since you don't get the mouseReleased() from MouseInputHandler, and leaving the list in "isAdjusting == true"-mode when a drag is aborted makes my selection stuff not work.
    My solution was to explictly call comp.setValueIsAdjusting(false) in my exportDone() function of my custom TransferHandler. Now everything is cool.

  • Help needed, stuck in a DnD JList problem

    Hi guys
    I got this code from internet and I was really expecting it would work, but it is not really transferring my Object to the other JList.
    I someone can help me I would appreciate that very much, below is the code, to the Model and to the Transfer.
    Model
    public class TabVernizListModel extends AbstractListModel {
        ArrayList<TabelaVerniz> lista;
        public TabVernizListModel(ArrayList<TabelaVerniz> lista) {
            this.lista = lista;
        public TabVernizListModel() {
            lista = new ArrayList<TabelaVerniz>();
        public Object getElementAt(int index) {
            Object item = null;
            if (lista != null) {
                item = lista.get(index);
            return item;
        public Integer getSelectedIndex(TabelaVerniz item) {
            int index = lista.indexOf(item);
            return index;
        public int getSize() {
            int size = 0;
            if (lista != null) {
                size = lista.size();
            return size;
        public void remove(int index) {
            fireIntervalRemoved(this, index, index);
            lista.remove(index);
        // This is not really working, does not update the 2nd List
        public void add(TabelaVerniz tabela) {
            if (lista == null) {
                lista = new ArrayList<TabelaVerniz>();
            lista.add(tabela);
            int index = this.getSelectedIndex(tabela);
            super.fireIntervalAdded(this, lista.size() - 1, lista.size() - 1);
    The Transfer:
    public class TabVernizTransferHandler extends TransferHandler {
        JList listaEsquerda;
        JList listaDireita;
        // This transfer handler needs to know about the two JLists !
        public TabVernizTransferHandler(JList leftList, JList rightList) {
            super();
            listaEsquerda = leftList;
            listaDireita = rightList;
        @Override
        public boolean importData(JComponent component, Transferable trasferedObject) {
            JList lista = (JList) component;
            try {
                int sourceIndex = Integer.parseInt((String) trasferedObject.getTransferData(DataFlavor.stringFlavor));
                // figure out which is the source and which is the dest.
                TabVernizListModel source;
                TabVernizListModel dest;
                if (lista == listaEsquerda) {
                    source = (TabVernizListModel) listaDireita.getModel();
                    dest = (TabVernizListModel) listaEsquerda.getModel();
                } else {
                    source = (TabVernizListModel) listaEsquerda.getModel();
                    dest = (TabVernizListModel) listaDireita.getModel();
                // get the source object
                TabelaVerniz tabela = (TabelaVerniz) source.getElementAt(sourceIndex);
                // add it to the other model.
                dest.add(tabela);
                // and remove from the source
                source.remove(sourceIndex);
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("Import failed!");
                return (false);
            return (true);
        @Override
        protected Transferable createTransferable(JComponent c) {
            JList jl = (JList) c;
            // we want the currently selected index
            Integer index = new Integer(jl.getSelectedIndex());
            // and we transfer it as a string
            Transferable t = new StringSelection(index.toString());
            return t;
        @Override
        public int getSourceActions(JComponent c) {
            return MOVE;
        @Override
        public boolean canImport(JComponent c, DataFlavor[] flavors) {
            for (int i = 0; i < flavors.length; i++) {
                if (flavors.getHumanPresentableName().equals("Unicode String")) {
    return (true);
    return (false);
    }Can anyone point what is wrong here?
    When I drag from the left list to the right list it just don't drop.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    The Swing tutorial on Drag and Drop has a working example with a JList.

  • Splash Screen + Jar + DND + Linux = XServer Freeze?

    I've experienced a strange problem with one of my programs which I believe to be a java bug, I just need help reproducing it in a small example.
    Basically, I have a fairly large project (20,000 loc), which involves a bit of drag and drop of a custom JTree, custom JList, and some other things. Recently, we introduced a splash screen to the project. With that, I started getting reports of the program freezing people's linux computers. I looked into it and was able to reproduce the problem. Here are my findings:
    1) Disabling the splash screen stops the freezing. This is an undesirable workaround, since the program takes a long time to load, but aside from disabling Drag and Drop, this has been the only workaround I've found so far.
    2) The freezing only occurs if the project is packed into a jar. Running from Eclipse or running the class files does not produce the problem.
    3) The freeze occurs briefly after the user completes a Drag and Drop. There are other methods to complete these actions which do not involve drag and drop, but these methods do not cause the freeze, thus the problem is with the DND.
    4) I was unable to reproduce this problem with Windows
    Upon freezing, I am still able to move the mouse cursor, but it get stuck on a certain pointer (which, since this is briefly after the DND completion, could be anything. I've obtained states such as invisible, I-beam, and pointer). Music also continues to play. Open windows, however, stop responding to attempts to bring them to front, minimize them, interact with them, etc - they are essentially frozen. Ctrl+C does not kill the offending process, even if it was run from the terminal.
    There are 2 ways to recover from the freeze: Hard Reboot, or ssh in and kill the java process that way.
    This has led me to conclude that it is the XServer freezing.
    Now the weird thing is, I'm unable to reproduce this with a small test program which involves all 4 of the mentioned components.
    Anybody know anything about this problem? Anybody else experienced this or able to reproduce this?
    My project is open source and I'd be more than happy to share a jar of it if it helps you any, or it can be accessed from an SVN. Like I said, though, it's 20,000 loc or so, so I doubt you'd want to look through it to find the problem. I've also created a small test program using the main freeze-worthy components (Splash screen, jar, DND), but it does not cause the freeze. I can provide that program if anybody's interested.
    Please help, this is very irritating, and I'm starting to get some unhappy clients.

    OK, so I managed to replicate it on relatively small code, here comes the code:
    DomTree.java
    import javax.swing.JFrame;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import java.math.BigDecimal;
    public class DomTree extends JTree
        public DomTree()
         DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
         root.add(new DefaultMutableTreeNode(new BigDecimal(Math.PI)));
         root.add(new DefaultMutableTreeNode(new BigDecimal(Math.E)));
         root.add(new DefaultMutableTreeNode(new BigDecimal(Math.PI*Math.E)));
         setModel(new DefaultTreeModel(root));
         new DomTreeDnD(this);
        public static void main(String args[]) {
         JFrame frame = new JFrame();
         frame.setSize(640, 480);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.add(new DomTree());
         frame.setVisible(true);
    }DomTreeDnD.java
    import java.awt.Component;
    import java.util.ArrayList;
    import java.io.IOException;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.UnsupportedFlavorException;
    import java.math.BigDecimal;
    import javax.swing.DropMode;
    import javax.swing.JComponent;
    import javax.swing.JTree;
    import javax.swing.TransferHandler;
    import javax.swing.tree.TreePath;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    public class DomTreeDnD extends TransferHandler
        /** A list of supported data flavors for import */
        public DataFlavor importFlavors[] = null;
        /** A list of supported data flavors for export */
        public DataFlavor exportFlavors[] = null;
        // BigDecimal transfer within the same JVM instance:
        DataFlavor localBigDecimal;
        public DomTreeDnD(DomTree domTree)
         try {
             // BigDecimal transfer within the same JVM instance:
             localBigDecimal = new DataFlavor(BigDecimal.class, "Big Number");
             importFlavors = new DataFlavor[]{
              localBigDecimal, // JVM-local import
             ArrayList<DataFlavor> exportFlavors = new ArrayList<DataFlavor>();
             exportFlavors.add(localBigDecimal);
             this.exportFlavors = exportFlavors.
              toArray(new DataFlavor[exportFlavors.size()]);
             domTree.setTransferHandler(this);
             domTree.setDragEnabled(true);
             domTree.setDropMode(DropMode.INSERT);        
         } catch (IllegalArgumentException iae) {
             System.err.println("D&D is disabled due to: "+iae);
        /* In order to restrict drop location, remember what is being dragged: */
        /** Source component (of class DomTree) noted upon drag. */
        Component source = null;
        /** The DomTree in which internal MOVE action has been performed.*/
        DomTree selectTree = null;
        /** The position in DomTree where internal MOVE action has been performed.*/
        TreePath selectPos = null;
        /** Export (start drag or copy): declare supported actions */
        public int getSourceActions(JComponent c)
         // support only DomTree (for now)
         if (c instanceof DomTree) {
             System.out.println("getSourceActions: OK");
             return COPY_OR_MOVE;
         return NONE;
        /** Export (start drag or copy): wrap the data */   
        protected Transferable createTransferable(JComponent source)
         if (source instanceof DomTree) {
             DomTree domTree = (DomTree) source;
             TreePath path = domTree.getSelectionPath();
             if (path == null) return null;
             Object o = path.getLastPathComponent();
             if (o == null) return null;
             if (!(o instanceof DefaultMutableTreeNode)) return null;
             o = ((DefaultMutableTreeNode)o).getUserObject();
             if (o instanceof BigDecimal) {
              System.out.println("createTransferable");
              BigDecimal t = (BigDecimal)o;
              return new TransferableBigDecimal(t);
             } else {
              System.out.println("Dragging "+o.getClass().getName());
         return null; // otherwise drag is not supported
        /** Export (drag or copy): finish export after import is done */
        protected void exportDone(JComponent source,
                         Transferable data, int action)
         if (selectTree != null && selectPos != null) {
             System.out.println("exportDone: change selection");
             selectTree.setSelectionPath(selectPos);
             selectTree = null;
             selectPos = null;
             System.out.println("exportDone: change selection done");
        /** Import (drop or paste): find acceptable flavor. */
        DataFlavor findFlavor(Transferable transferable)
            for (DataFlavor idf: importFlavors)// prefer our priorities first
             if (transferable.isDataFlavorSupported(idf)) {
              return idf;
            System.out.println("No supported data flavor found, suggested:");
            for (DataFlavor df: flavors)
                System.out.println(df);
            return null;     
        /** Import (drop or paste): can we accept the flavor? */
        public boolean canImport(JComponent c, DataFlavor[] flavors)
         System.out.println("canImport DataFlavor");
         for (DataFlavor idf: importFlavors)// prefer our priorities first
             for (DataFlavor edf: flavors)
              if (idf.equals(edf)) return true;
         return false;
        /** Import (drop or paste): can we accept the stuff? asked continuousely.*/
        public boolean canImport(TransferHandler.TransferSupport sup)
         if (!sup.isDrop()) // allow only drop
             return false;
         // allow only copy and move:
         if (sup.getUserDropAction() != COPY_OR_MOVE &&
             sup.getUserDropAction() != COPY &&
             sup.getUserDropAction() != MOVE)
             return false;
         Component target = sup.getComponent();
         if (!(target instanceof DomTree)) // support only DomTree
             return false;
         DomTree domTree = (DomTree)target;
         // check for compatible flavor:
         if (findFlavor(sup.getTransferable()) == null) return false;
         JTree.DropLocation loc = (JTree.DropLocation)sup.getDropLocation();
         TreePath destPath = loc.getPath();  // parent of drop position
         int destIndex = loc.getChildIndex();// position of insertion
         if (destPath == null) return false;
         Object parent = destPath.getLastPathComponent();
         parent = ((DefaultMutableTreeNode)parent).getUserObject();
         if (!(parent instanceof String)) // drop only within document
             return false;
         if (target == source) { // transfer within the same tree
             sup.setDropAction(sup.getUserDropAction());
         return true; // allow transfer
        /** Import (drop or paste): perform import and return result. */
        public boolean importData(TransferHandler.TransferSupport sup)
         Component target = sup.getComponent();
         if (!(target instanceof DomTree)) return false;
         DomTree domTree = (DomTree)target;
         Transferable trans = sup.getTransferable();
         DataFlavor flavor = findFlavor(trans);
         if (flavor==null) return false;
         System.out.println("importData");
         BigDecimal t = null;
         // extract the data being dropped:
         try {     
             Object data = trans.getTransferData(flavor);
             if (data == null) return false;
             if (flavor.equals(localBigDecimal)) {
              if (data instanceof BigDecimal) t = (BigDecimal)data;
              else return false;
         } catch (UnsupportedFlavorException ufe) {
             ufe.printStackTrace(System.err);
         } catch (IOException ioe) {
             ioe.printStackTrace(System.err);
         if (t == null) return false; // data extraction failed
         System.out.println("Search for location");
         // search for position in terms of a preceeding template:
         JTree.DropLocation loc = (JTree.DropLocation)sup.getDropLocation();
         TreePath destPath = loc.getPath();
         int destIndex = loc.getChildIndex();
         DefaultMutableTreeNode pos;
         DefaultTreeModel model = (DefaultTreeModel)domTree.getModel();
         DefaultMutableTreeNode parent =
             (DefaultMutableTreeNode)model.getRoot();
         System.out.println("Insert a copy");
         BigDecimal copy = new BigDecimal(t.doubleValue());
         pos = new DefaultMutableTreeNode(copy);
         parent.insert(pos, destIndex);
         TreePath path = destPath.pathByAddingChild(pos);
         model.nodesWereInserted(parent, new int[]{destIndex});
         System.out.println("Highlight selection");
         // highlight the selection in the DomTree:
         if (pos != null) {
             domTree.setSelectionPath(path);
         return true;
        class TransferableBigDecimal implements Transferable
         protected final BigDecimal template; // hidden behind interface
         public TransferableBigDecimal(BigDecimal t) {
             System.out.println("TransferableBigDecimal");
             template = t;
         public boolean isDataFlavorSupported(DataFlavor df) {
             if (!localBigDecimal.equals(df))
              System.out.println("Tried requesting: " + df);
             for (DataFlavor myflavor: exportFlavors)
              if (myflavor.equals(df))
                  return true;
             return false;
         public Object getTransferData(DataFlavor df)
             throws UnsupportedFlavorException, IOException
             if (df.equals(localBigDecimal)) {
              System.out.println("Local export");
              return template;
             } else {
              System.out.println("Unsuported flavor");
              throw new UnsupportedFlavorException(df);
         public DataFlavor[] getTransferDataFlavors() {
             System.out.println("Asked for all supported flavors");
             for (DataFlavor df: exportFlavors)
              System.out.println(df);
             return exportFlavors;
    }manifest
    Manifest-Version: 1.0
    Main-Class: DomTree
    SplashScreen-Image: splash.pngsplash.png
    // use gimp to draw 400x300 picturecompile:
    javac DomTree.javacreate jar:
    jar -cvfm dndtest.jar manifest splash.png DomTree*.class DomTreeDnD*.classrun:
    java -jar dndtest.jarthen select any number and try to drag -- the screen freezes.
    interestingly, if you tried running this DomTree not in a jar, then it does not freeze anymore, you will need to logout/login to replicate the freeze.

  • How do I restrict the source trying to access a port?

    I have VoIP phones in my office and I am experiencing dozens of hacking attempts per day.  I received the following email from the company that I purchase service from:
    Hi ,
    Based on our research and experience with these type of calls, these are hacking attempts usually using a program called SIP Vicious or a variant. You can  check the link below about SIP Vicious.
    http://threatpost.com/hackers-pushing-sipvicious-voip-tools-malicious-attacks-08 3111/
    These attacks for the most part do not affect users behind our managed routers since we have security features in place to block them.
    The calls that the remote users are getting do not  traverse the Broadcorenetwork at all. Meaning even if the user put the phone on  DND or we try to block calls through the Web portal, calls will still go through because the call does not go through our Session Border Controller ( SBC ) .
    The call is directly hitting the IP of the remote users router (bypassing Broadcore completely) and scanning the ports for a SIP device which is the Polycom Phone. Once they get an answer back from the phone, the hacker  now has a target to attack. What they want to do is get the credentials for the user so they can authenticate a soft phone for example and make free calls.
    Unmanaged network /Router limits us of how we can block these calls  , however we have a suggestion which could help you eliminate these calls.
    What the remote user can do is to implement this policy . Allow UDP protocol on port 5060 but the only source should be west.broadcore.com.
    Since the remote user uses his/her own router, you might need help from their respective support team.
    Thank you,
    How do I set up the port mapping to only allow incoming traffic from the specified source west.broadcore.com?
    Also, is there some sort of documentation, manual, web site or book that covers what the settings of the Airport are?  In detail?  So, that I can learn for myself what is what and be able to answer my own questions such as:  Timed Access - Does this only apply to Wi-Fi or does it disable to whole router during the restricted period?
    Thanks in advance,
    Noa
    By the way I'm using the  Airport Express 802.11n Wi-Fi (2nd Generation), Firmware 7.6.4, Airport Utility 6.3.4 on my Mac or the latest version on my iPhone 6.

    What the remote user can do is to implement this policy . Allow UDP protocol on port 5060 but the only source should be west.broadcore.com.
    Unfortunately, Apple routers are quite simple, and do not have the features and settings that you would need to do this.
    However, if you are using a modem/router or gateway device with the AirPort Express, then you might be able to set up the modem/router to do what you need. What is the make and model number of the device that you likely call your "modem"?

  • DnD icon won't go away on Redhat 9

    Background:
    I recently updated my OS to RedHat 9 (2.4.20-6). Previously on Redhat 7.3 (kernel upgraded to 2.4.18ish) everything worked OK.
    java -version
    java version "1.4.1-beta"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
    Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
    Problem:
    After dragging and dropping an object the drag icon/cursor turns black/reverse-video and does not go away until I drag another object or move the icon/cursor out of the window. The problem did not occur before my upgrade so I imaging it is not a java problem. I would like to know if anyone can repeat the problem or if anyone else has seen it. One Caveate... if you do anything after the drop that causes an icon repaint (like the OptionPane that is commented out in the code below) the problem does not appear. I have not been able to reproduce the problem outside of java.
    thanks
    Brad
    Example:
    This code by Gupta is a simple example to demonstrate the problem.
    file DNDComponentInterface.java
    <code>
    public interface DNDComponentInterface{
    public void addElement( Object s);
    public void removeElement();
    </code>
    file DNDList.java
    <code>
    /**his is an example of a component, which serves as a DragSource as
    * well as Drop Target.
    * To illustrate the concept, JList has been used as a droppable target
    * and a draggable source.
    * Any component can be used instead of a JList.
    * The code also contains debugging messages which can be used for
    * diagnostics and understanding the flow of events.
    * @version 1.0
    import java.awt.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.util.Hashtable;
    import java.util.List;
    import java.util.Iterator;
    import java.io.*;
    import java.io.IOException;
    import javax.swing.*;
    import javax.swing.JList;
    import javax.swing.DefaultListModel;
    public class DNDList extends JList
    implements DNDComponentInterface, DropTargetListener,DragSourceListener, DragGestureListener {
    * enables this component to be a dropTarget
    DropTarget dropTarget = null;
    * enables this component to be a Drag Source
    DragSource dragSource = null;
    * constructor - initializes the DropTarget and DragSource.
    public DNDList() {
    dropTarget = new DropTarget (this, this);
    dragSource = new DragSource();
    dragSource.createDefaultDragGestureRecognizer( this, DnDConstants.ACTION_MOVE, this);
    * is invoked when you are dragging over the DropSite
    public void dragEnter (DropTargetDragEvent event) {
    // debug messages for diagnostics
    System.out.println( "dragEnter");
    event.acceptDrag (DnDConstants.ACTION_MOVE);
    * is invoked when you are exit the DropSite without dropping
    public void dragExit (DropTargetEvent event) {
    System.out.println( "dragExit");
    * is invoked when a drag operation is going on
    public void dragOver (DropTargetDragEvent event) {
    System.out.println( "dragOver");
    * a drop has occurred
    public void drop (DropTargetDropEvent event) {
    try {
    Transferable transferable = event.getTransferable();
    // we accept only Strings
    if (transferable.isDataFlavorSupported (DataFlavor.stringFlavor)){
    // KBS
    //event.acceptDrop(DnDConstants.ACTION_MOVE);
    //event.getDropTargetContext().dropComplete(true);
    // KBS
    // KBS Added this
    /* You must leave this commented out to replicate the DND icon ghost problem
    int answer = JOptionPane.showConfirmDialog(this,
    "Are you sure?",
    "Warning",
    JOptionPane.YES_NO_OPTION);
    int answer = JOptionPane.YES_OPTION;
    if (answer == JOptionPane.YES_OPTION)
    // KBS To here
    event.acceptDrop(DnDConstants.ACTION_MOVE);
    String s = (String)transferable.getTransferData ( DataFlavor.stringFlavor);
    addElement( s );
    event.getDropTargetContext().dropComplete(true);
    // KBS Added this
    // KBS To here
    else{
    event.rejectDrop();
    catch (IOException exception) {
    exception.printStackTrace();
    System.err.println( "Exception" + exception.getMessage());
    event.rejectDrop();
    catch (UnsupportedFlavorException ufException ) {
    ufException.printStackTrace();
    System.err.println( "Exception" + ufException.getMessage());
    event.rejectDrop();
    * is invoked if the use modifies the current drop gesture
    public void dropActionChanged ( DropTargetDragEvent event ) {
    * a drag gesture has been initiated
    public void dragGestureRecognized( DragGestureEvent event) {
    Object selected = getSelectedValue();
    if ( selected != null ){
    StringSelection text = new StringSelection( selected.toString());
    // as the name suggests, starts the dragging
    dragSource.startDrag (event, DragSource.DefaultMoveDrop, text, this);
    } else {
    System.out.println( "nothing was selected");
    * this message goes to DragSourceListener, informing it that the dragging
    * has ended
    public void dragDropEnd (DragSourceDropEvent event) {  
    if ( event.getDropSuccess()){
    removeElement();
    * this message goes to DragSourceListener, informing it that the dragging
    * has entered the DropSite
    public void dragEnter (DragSourceDragEvent event) {
    System.out.println( " dragEnter");
    * this message goes to DragSourceListener, informing it that the dragging
    * has exited the DropSite
    public void dragExit (DragSourceEvent event) {
    System.out.println( "dragExit");
    * this message goes to DragSourceListener, informing it that the dragging is currently
    * ocurring over the DropSite
    public void dragOver (DragSourceDragEvent event) {
    System.out.println( "dragExit");
    * is invoked when the user changes the dropAction
    public void dropActionChanged ( DragSourceDragEvent event) {
    System.out.println( "dropActionChanged");
    * adds elements to itself
    public void addElement( Object s ){
    (( DefaultListModel )getModel()).addElement (s.toString());
    * removes an element from itself
    public void removeElement(){
    (( DefaultListModel)getModel()).removeElement( getSelectedValue());
    </code>
    file TestDND.java
    <code.
    * The tester class for the DNDList. This class creates the lists,
    * positions them in a frame, populates the list with the default
    * data.
    * @version 1.0
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TestDND
    public static void main (String args[]) {
    TestDND testDND = new TestDND();
    * constructor
    * creates the frame, the lists in it and sets the data in the lists
    public TestDND()
    JFrame f = new JFrame("Drag and Drop Lists");
    DNDList sourceList = new DNDList();
    // add data to the source List
    DefaultListModel sourceModel = new DefaultListModel();
    sourceModel.addElement( "Source Item1");
    sourceModel.addElement( "Source Item2");
    sourceModel.addElement( "Source Item3");
    sourceModel.addElement( "Source Item4");
    // gets the panel with the List and a heading for the List
    JPanel sourcePanel = getListPanel(sourceList, "SourceList", sourceModel);
    DNDList targetList = new DNDList();
    // add data to the target List
    DefaultListModel targetModel = new DefaultListModel();
    targetModel.addElement( "Target Item1");
    targetModel.addElement( "Target Item2");
    targetModel.addElement( "Target Item3");
    targetModel.addElement( "Target Item4");
    JPanel targetPanel = getListPanel(targetList, "TargetList", targetModel);
    JPanel mainPanel = new JPanel();
         mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.add( sourcePanel );
    mainPanel.add( targetPanel );
    f.getContentPane().add( mainPanel );
    f.setSize (300, 300);
    f.addWindowListener (new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    f.setVisible (true);
    * a convenience method
    * used for positioning of the ListBox and the Label.
    * @param list - the special DND List
    * @param labelName - the heading for the list
    * @param listModel - model for the list
    private JPanel getListPanel(DNDList list, String labelName, DefaultListModel listModel ){ 
    JPanel listPanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane(list);
    list.setModel(listModel);
    JLabel nameListName = new JLabel(labelName );
    listPanel.setLayout( new BorderLayout());
    listPanel.add(nameListName, BorderLayout.NORTH);
    listPanel.add( scrollPane, BorderLayout.CENTER);
    return listPanel;
    </code>

    HI,
    Try Resetting your iPhone
    Carolyn

  • How to restrict FBL1N only to display access

    Hi,
    I need some help in restricting access for FBL1N.   The requirement is the user should be able to only display the vendor items  for the given opcos.  I created a test role for this tcode and maintained the activity for all the auth objects to 03.   But still user is able to change the vendor details.   When ran trace, it was showing the access to Tcode FB02.  but not sure how the test user is getting this access as the test role does not contain FB02 and user does not have any other role. Please advise
    Regards
    Kavitha

    Raghu Boddu wrote:
    Hi Kavitha,
    >
    > FBL1N internally calls lots of tcodes and FB02 is one among them. Check the table TCDCOUPLES.
    >
    > I don't think this restriction is possible only with adding 03 activity for the F_LFA1*  and F_BKPF* objects.
    >
    > If you check FBL1N in SU24, there are a few other authorization objects that are in check state. You need to make them check maintain and further maintain the activites in the individual roles.
    >
    > However, this may impact on the current roles that have FBL1N transaction code.
    >
    > Hope this helps!!
    >
    > Regards,
    > Raghu
    Despite the SAP_ALL removing the authorization problem.... I would like to enquire about this post.
    Can you please explain each of the statements you have made and provide some evidence?
    If the user has the correct authorizations then they are are wrong and the "check" and "check/maintain" status has no impact on the coding in customer type systems.
    Cheers,
    Julius

  • Restricting List of credit card displayed while creating Order

    Dear All,
           We have an issue where there are various different payment card types setup in SAP CRM for transaction TA. Among these all payment cards setup, I want to restrict and show only a few for US Sales Org and rest of them for UK sales org. as a selection option to the user. Is there a BADI which I can use to put such restrictions or it is going to be a UI specific development i.e. a seperate code for ISA, Web UI, SAP GUI etc.
    Regards,
    Vivek

    well .. this is working for me right now. Will post back if I get fired for lack of available resources ( both system and user )

  • Restricting application of Digital Signatures

    Hello,
    I am trying to determine what options are available natively in Acrobat for restricting the type of certificate that is used for applying a digital signature.  As far as I can tell, Acrobat, by default, seems to allow the use of any certificate which has the "Digital Signature" extension.  This has the potential to create large problems in a regulated environment.
    In my organization, our users receive multiple certificates for different applications.  For instance, a user may have a certificate for VPN access, one for SMIME email and finally, one that is specifically for applying eSignatures.  There is a more robust vetting process for obtaining an eSignature certificate, and it also prompts for a passphrase each time the private key is accessed.  Each type of certificate comes from a separate CA.
    We've configured the Trusted Identities in each user's Acrobat by deploying an addressbook file to them.  We've only defined our eSignature CA as a trusted CA in Acrobat (along with some other universally trusted authorities).  The result is that when a signature that has been applied using any other CA, Acrobat will not verify the signature.  This is good, but it is not good enough since the dynamic images that come with Acrobat digital signatures do not appear on printed or flattened documents.
    Basically, I'm trying to determine whether there is a way to configure Acrobat (natively, out-of-the-box) such that it will only allow application of digital signatures using certificates that are issued from a CA that is defined as a Trusted Identity.
    Has anyone encountered this before?

    Hi Mike,
    The short answer is yes, you can restrict signing to a certain type of certificate. However, you do need to be able to edit each PDF file that needs to be signed.
    To expand a bit, the process is know as applying a Seed Value. There are two different types of PDF files and they each have a different method of applying Seed Values. If the PDF is an XML template that was created using LiveCycle Designer, then you can apply the Seed Value to the signature field using the Designer software. On the other hand, if the PDF file is the more ubiquitous AcroForm (e.g. you converted a Word Doc to PDF), then you have to use JavaScript to apply the Seed Value.
    Before I get into the specifies of applying a Seed Value, first here is what a Seed Value can do. Among other things, you can use Seed Value to restrict signing to:
    a specific user's digital ID
    digital IDs issued by a specific CA
    a digital ID that has a specific key usage value (it sounds like this is what you are looking for)
    If you need to use JavaScript you are doing to want to review the published JavaScript guide. You can find the guide online at http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/wwhel p.htm?href=JS_API_AcroJSPreface.87.1.html#1515775&accessible=true and search search for Seed Value. More specifically, you are looking for the JavaScript call signatureSetSeedValue and the section (about half way down the page) CertificateSpecifier Object. At the bottom of the page are examples of how to set the certspec object.
    If you are using LiveCycle Designer you need to display the Object pallet. Select the Window > Object menu item to get the Object pallet to display. Then, select the signature field that you want to apply the Seed Value to, select the Signature tab in the Object pallet, and then click the Settings button. This is the dialog you use to apply the Seed Value.
    Good luck and let me know if you need more help,
    Steve

  • 1.4.2 JList to JList drag n drop example?

    Could anyone provide (or point me to) a jsdk1.4.2 example of drag and drop from one JList to another? What I'd really like is multiple (say 3 or 4) JLists that can all drag and drop multiple items between each other (supporting multi-select).

    Look for ExtendedDnDDemo [url http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html]here.

Maybe you are looking for

  • VHS to DV distortion

    I have an off the shelf VHS deck output to Canopus ADVC 110 to MacPro/FCP for capturing VHS tapes. Can someone suggest a method/hardware for eliminating the distortion I receive as seen in this link? http://www.tedean.com/ThomasDean/VHSDemo.html Than

  • Approval workflow triggers when not expected for SRM PO & without Agent ??

    Hi All, We are using SRM 5.0 integrated with SAP MM backends. We are frequently facing this problem, when a buyer  creates a PO (in SRM) within his/ her Spending (Output) Limit, the PO approval workflow triggers and is not able to find an agent. Alth

  • Flash CS4 Library Question

    Hello, Is there a way to know how many times a library item is being used in your Flash file? Thanks! Erin S.

  • Restore comments in iweb

    hello, i seem to have lost all my blog comments on my .mac published site. i have a saved "domain" file with all my old comments still showing when i open it but when i try to re-publish to .mac it still shows 0 comments on all my blog entries. is th

  • Customizing the DVD ROM content

    Hi, I added in the DVD ROM content of one of my film photos from iPhoto. I have a few issues I want to resolved: - The folder is named with the name of my iDVD file, and not with the name of my iDVD Project (in Project/Project info). Anyway to force