This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Disable dropping feature in JSpinner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disable dropping feature in JSpinner" Watch "Disable dropping feature in JSpinner" New topic
Author

Disable dropping feature in JSpinner

James Peter
Ranch Hand

Joined: Sep 15, 2010
Posts: 115
Hi All,

I need to avoid dropping of text inside the JSpinner control. Below is my code for custom transferHandler.
Even though canImport method is returning false I am able to drag and drop text into JSpinner.
I searched net but did not find proper solution. Please let me know if any one is having an idea how to do it.



Thanks
Peter
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
have you tried setting the spinner's
formattedTextfield's allowInvalidCharacters
to false?
(posting from phone, so method name
might not be exact)
James Peter
Ranch Hand

Joined: Sep 15, 2010
Posts: 115
Hi,
Below code is working. thanks a lot.


Thanks
Peter
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
correct, but the method belongs to the
formattedTextfield of the spinner.

read the spinner docs to get the formattedTextfield

[edit]
thanks to the previous post being edited, my post now makes no sense.
I replied to the unedited post which said 'couldn't find the method in the JSpinner class'
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Disable dropping feature in JSpinner
 
Similar Threads
Drag and Drop within the JTable
Cannot get TransferHandler to work in Swing
Drag and Drop from JList to JTable.
TransferHandler to dnd files from OS desktop to JTable
Drag cursor not changing, but drop succeeding.