java

Dynamically refresh JTextArea as processing occurs?

I am trying to create a very simple Swing UI that logs information onto the screen via a JTextArea as processing occurs in the background. When the user clicks a button, I want each call to: textArea.append(someString + "\n"); to immediately show up in the UI. At the moment, the JTextArea does not show all log information until the ...

Can I permanently prevent Java security updates from installing Yahoo Toolbar?

Each time I get a Java security update, I have to remember to untick the box to install the yahoo toolbar browser plugin that they've decided, for some mad reason, is an important security feature of Java. Is there a way to get it to remember my choice, or to get the security updates without it? Or to educate Sun about what is and isn'...

How to notify the user of important events for a desktop application?

Our customer is using our software (Java Swing application started using Webstart) besides other software like MS Office, to do his job. From time to time there are important events he has to deal with in our software without much delay. The customer wants to have a prominent notification then. Now he might be using Excel at the moment, ...

Java Swing 1.6 to 1.5

Is it possible to port a UI developed using Swing in Java 1.6 to Java 1.5 without rewriting all again? ...

How to retrieve a list of deprecated methods from a class

How do I retrieve a list of deprecated methods from a class. I need to list the methods that have been marked as deprecated for a class to pass on to documentation. I don't really want to copy and paste each method and its javadoc into a seperate file, is it possible to do this through the javadoc tool or through eclipse? ...

Linkify text with regular expressions in Java

I have a wysiwyg text area in a Java webapp. Users can input text and style it or paste some already HTML-formatted text. What I am trying to do is to linkify the text. This means, converting all possible URLs within text, to their "working counterpart", i.e. adding < a href="...">...< /a>. This solution works when all I have is plain ...

How do I pass formated (\n \t) text to a java command line

I need to pass a formatted string in a command line so that the input text is presented formatted in a JFrame: Hello The sun is shinning! How do I put a '\n' in a Windows batch file? java -cp . Test "Hello\nThe sun is shinning!" I cannot change the program, it is expecting a string as a command line parameter to be shown in a TextB...

How do you customize exception handling behavior in JUnit 3?

I want to implement exception checking (like in JUnit 4) using JUnit 3. For example, I would like to be able to write tests like this: public void testMyExceptionThrown() throws Exception { shouldThrow(MyException.class); doSomethingThatMightThrowMyException(); } This should succeed if and only if a MyException is thrown. Th...

problem with Random.nextGaussian()

Random.nextGaussian() is supposed to give random no.s with mean 0 and std deviation 1. Many no.s it generated are outside range of [-1,+1]. how can i set so that it gives normally distributed random no.s only in the range -1 to 1. ...

What is the most efficient Java Collections library?

What is the most efficient Java Collections library? A few years ago, I did a lot of Java and had the impression back then that trove is the best (most efficient) Java Collections implementation. But when I read the answers to the question "Most useful free Java libraries?" I noticed that trove is hardly mentioned. So which Java Collect...

How to script the java debugger command-line tool (jdb)?

How can I drive the debugging session with some scripting language like ruby? Is there any easier options than using Expect or some similar module with a scripting language? ...

Hibernate is calling public methods on the entities after a query, why?

I'm using hibernate 3.0 (with posgre 8.3), Java 1.6 and Netbeans 6.5. I've created one native query to return all the unique most recent entries like this: String query = "SELECT DISTINCT ON (origem) * FROM entrada " + "ORDER BY origem, horadata DESC"; SQLQuery sqlQuery = this.getSession().createSQLQuery(query); ...

Is there a java api to access bugzilla?

Is there a (standalone!) java api which wraps the XML-RPC interface to bugzilla? I don't want to program my own api for it, and I can't actually find a library which does this (and only this). Update: I'm looking for something like this http://oss.dbc.dk/bugzproxy/ only written in Java ...

Is there any reasonable SSDP or DIDL Lib for java/groovy/python?

For a future project I am looking for a library to handle SSDP communication and messages in DIDL-Lite xml dialect. Is there any reasonable implementation of java, groovy or python? I don't like to use implementations of existing UPnP stacks like cybergarage or the frauenhofer UPnP stack because they are highly depending on these stack...

Compare two arrays of primitives in Java?

I know about Arrays.deepEquals(Object[], Object[]) but this doesn't work for primitive types (due limitations of arrays and autoboxing, see this related post). With that in mind, is this the most efficient approach? boolean byteArrayEquals(byte[] a, byte[] b) { if (a == null && b == null) return true; if (a == null || ...

Microsoft vs Java Career

If you could choose between becoming an expert in Microsoft or Java, which one would you choose and on what grounds? Does one of the two have a better future? Will you earn more in one of the two? Is one of the two better and faster in developing solutions? Do they both have the same possibilities in Cloud Computing? And do you have...

Using checkstyle with Ant during an automated eclipse build

For the last months I've been slowly improved the Eclipse automated PDE build process for our application. The first thing I tried was automating the test cases. The next step was some scripting code to generate an installer automatically, for both linux and windows. Now I want to add some static code analysis reports to the process. ...

Java - inconsistent behavior of instanceof

Is there anything tricky I should know about instanceof? I'm passing a list of objects through a few methods and testing whether these objects implement a particular interface using instanceof. In some cases, instanceof correctly identifies objects as implementing the interface, in other cases it doesn't. It appears to be giving me incon...

Improving Comparable<T> compareTo performance

I profiled my code and found out that my class, which implements Comparable<T>, spends 8x more cpu time in compareTo(Object) than in compareTo(T) I assume that the slowdown is because of virtual table lookup for this method. Is there a way to force static invocation of the function? (like in non virtual C++ methods) I still wa...

In Java, given an object, is it possible to override one of the methods?

I have an object of class A. I want to override one of the methods of that class. Can this be done? More specifically, I have an object that is being injected into a field. I need to override one of the methods, before I can use it. I am trying to see if Reflection could help solve the problem. Note that the method that I am trying o...