Skip to content

Tag: java

How to change the cursor type

This question is related to the previous post. How to save file and read alt text http://freeimagehosting.net/image.php?dc73c3bb33.jpg How can I change the cursor to “Hand” only when the mouse pointed on grid which is not Null (contained images)? So far the cursor turn to “Hand” all ov…

List all files from a directory recursively with Java

I have this function that prints the name of all the files in a directory recursively. The problem is that my code is very slow because it has to access a remote network device with every iteration. My plan is to first load all the files from the directory recursively and then after that go through all files …

only one swing frame window opened at time

I developed one swing application but each time you run application new window is opened. I want that if one window is already opened other not allow to open. Answer Here is an example of a Java Single Application Instance: A single instance application is one that only allows for 1 of the application to run …

How to get Locale from its String representation in Java?

Is there a neat way of getting a Locale instance from its “programmatic name” as returned by Locale’s toString() method? An obvious and ugly solution would be parsing the String and then constructing a new Locale instance according to that, but maybe there’s a better way / ready soluti…

Map equality using Hamcrest

I’d like to use hamcrest to assert that two maps are equal, i.e. they have the same set of keys pointing to the same values. My current best guess is: which gives: The method assertThat(T, Matcher<T>) in the type Assert is not applicable for the arguments (Set<Map.Entry<Householdtypes,Double…

Dynamically formatting a string

Before I wander off and roll my own I was wondering if anyone knows of a way to do the following sort of thing… Currently I am using MessageFormat to create some strings. I now have the requirement that some of those strings will have a variable number of arguments. For example (current code): Now I nee…