Tom Landry

Ranch Hand
+ Follow
since May 26, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tom Landry

Working with a sample but encountering a casting issue.

It compiles fine but encounters the following error during execution.

Exception in thread "main" java.lang.ClassCastException: javax.swing.JSpinner$ListEditor$ListFormatter cannot be cast to javax.swing.text.DefaultFormatter
at SpinnerEditor.<init>(Main.java:60)
at Main.<init>(Main.java:44)
at Main.main(Main.java:27)

Not sure exactly how to cast this to get past the error.

10 years ago

Rob Camick wrote:

As originally mentioned, when in edit mode the left/right keys would move to the next cell as opposed to the next character.



Not true!!! The default behaviour is to move to the previous/next character.

Post your SSCCE that demonstrates this behaviour.



I never said moving to the next cell (in edit mode) was the default behavior but rather what the software was doing.

In any case we seem to be going in circles.

All I was simply asking is in what scenario would this unusual behavior be seen as it can't be replicated with a simplified sample.
10 years ago
The default behavior when in edit is that the left/right arrows moves the cursor to the next character.

As originally mentioned, when in edit mode the left/right keys would move to the next cell as opposed to the next character.

Adding the code listed above should have essentially disabled the left/right keys but instead has now caused the default behavior to occur instead of disabling.

Also as mentioned above, the only SSCCE available is the scenario is which it works as expected. Unable to replicate the issue with a smaller testcase.
10 years ago
Tried creating a simple sample but all works as expected.

The following code prevents the cursor from moving when inside a cell of a JTable.



When editing a cell, the existing code would use the right/left cursor keys to move from cell to cell as opposed to from character to character when editing a cell.

I planned to override the functionality by tossing in the above code as a test to see if it stops the functionality before I override it.
After placing in the above code, the above functionality no longer occurs, but now the cursor moves within the cell as I wanted which is to move from character to character instead of cell to cell.
Its great it works, but it really shouldn't. Essentially the default behavior has been restored when it should have really disabled the left/right keys.
I assume there is some underlying class someplace that is doing something to affect the behavior.

Since a sample can't be provided I am wondering in what scenarios would the e.consume() restore default functionality?
10 years ago

Stephan van Hulst wrote:Hashtable shouldn't have an order. The order in which elements appear depend on the insertion order of the elements, the hash function, the capacity of the table, and maybe some other factors.

It seems you are working with some legacy code. Hashtable, Enumeration and Vector are all obsolete in favor of HashMap, Iterator and List.

If you want to sort the elements in some way, you could do this: Map<Integer, Object> map = new TreeMap<>(table);

You now have a map that contains the same elements as the hash table, sorted by natural order of the keys.



Thanks, that worked great.
10 years ago
Utilizing a HashTable <Integer, Object> then using Enumeration to retrieve the data to be placed within a Vector.
The data is stored in the required order within the HashTable but retrieval appears to be in reverse order.
Usually with other objects like Arrays and stuff the data in retrieved starting with 0.
Why does HashTable operate in reverse order?
Other than going through some extra steps for reordering what is the method usually used to keep the HashTable order when retrieving?
(I am stuck using the HashTable object.)
10 years ago
I have a number of cells which are Dates and need to have them appear in the same format.
The samples I have seen usually create a new cell renderer object for each cell, even if its the same type.
Since I have a number of Date cells I thought it best to use a single object for each of the date cells, but after seeing the different samples I am wondering if there is something I may be missing where using the same cell renderer object could potentially be an issue.
10 years ago
I just started working with some samples today and from your post it appears (although not certain) that you are attempting to access the file directory and not through a web server.

If this is indeed the case, I believe you need to add something like the following.

<jnlp spec="1.0+" codebase="file://localhost/X:/path/to/jnlp/" href="software.jnlp">
10 years ago
Attempted another sample. This time nothing was happening.
Attempted to run it via the command prompt using javaws and was receiving an error.
Long story short I had to change my Java Security settings from High to Medium and now both samples work.
10 years ago
Running the sample from http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/ and all it does is prompt me to download the JNLP file which it does and then opens it in Wordpad.

What step is missing to get this sample to run properly?
10 years ago
Geesh, 30 seconds after posting I remembered:
this.setMinimumSize(minimumSize);
10 years ago
Lets say the JDialog opens 5x5.

The user is allowed to modify its size to be any size larger than 5x5 but is not allowed to make it smaller.
Is there such a property or will this have to be regulated via code?
10 years ago
I think I may already had a solution.
One piece I was missing was setting the JDialog to be modal.
By default, control was being passed back and I was never getting my values.
Once it was created as modal, now the code appears to wait so then I can gather my info.
Just a minor detail missed.
Will post back with confirmation soon.
10 years ago
All the samples I found use JOptionPane to return a single value.
I am looking to return two values from two Text fields.
Any recommendations?
10 years ago