java

JFileChooser.showSaveDialog(...) - how to set suggested file name

The bloated JFileChooser seems to be missing one feature: a way to suggest the file name when saving a file (the thing that usually gets selected so that it would get replaced when user starts typing). Do you know a way around this? TIA. ...

java double comparison epsilon

i wrote a class that tests for equality, less than, and greater than with two doubles in java. My general case is comparing price that can have an accuracy of a half cent. 59.005 compared to 59.395. Is the epsilon i chose adequate for those cases? thanks... private final static double EPSILON = 0.00001; /** * Returns true if two dou...

Java window buffering keystrokes until the user clicks with the mouse

Here's the basic idea: There is a java window (main) that opens another java window (child). When the child is created, part of the initialization sets the focus in the appropriate text field in the child window: childTextField.requestFocusInWindow(); childTextField.setCaretPosition(0); The child is generally opened through a seriou...

How do you enable JMX in Websphere?

I would like to use JConsole to monitor my Websphere application, but I am not sure how to enable JMX. ...

Is there a way in JMockit to call the original method from a mocked method?

In my mock class, I'm mocking method foo(). For some test cases, I want the mock implementation of foo() to return a special value. For other test cases, I want to use the real implementation of foo(). I have a boolean defined in my mock class so that I can determine in the mock method whether I want to return the special value, or us...

What does this mean in a stack trace?

I see this in a stack trace: myorg.vignettemodules.customregistration.NewsCategoryVAPDAO.getEmailContentByID(I)Lmyorg/pushemail/model/EmailContent; What does the "(I)L" mean? ...

Load FreeMarker templates from database

Hi, I would like to store my FreeMarker templates in a database table that looks something like: template_name | template_content --------------------------------- hello |Hello ${user} goodbye |So long ${user} When a request is received for a template with a particular name, this should cause a query to be executed, whi...

What is the best way to remove duplicates in an Array in Java?

I have an Array of Objects that need the duplicates removed/filtered. I was going to just override equals & hachCode on the Object elements, and then stick them in a Set... but I figured I should at least poll stackoverflow to see if there was another way, perhaps some clever method of some other API? ...

Spring Integration 1.0 RC2: Streaming file content?

I've been trying to find information on this, but due to the immaturity of the Spring Integration framework I haven't had much luck. Here is my desired work flow: New files are placed in an 'Incoming' directory Files are picked up using a file:inbound-channel-adapter The file content is streamed, N lines at a time, to a 'Stage 1' chan...

Java based Swing Browser should support JavaScript

In my company, I am implementing a java based html browser. I found a lot of tools to generate complete browsers only in Swing which are looking like Mozilla. But I was not able to find a browser which supports JavaScript. The browser I will implement should execute JavaScript inside the HTML sides. Do you know of a tool that supports t...

Timeouts not working using JavaMail 1.4

I'm using JavaMail to send email requests to an SMTP server. I'm setting both "mail.smtp.connectiontimeout" and "mail.smtp.timeout" properties to 5 and 30 seconds respectively and passing both of these to Session.getDefaultInstance(). However, when I go to do the Transport.send(), the timeouts I set appear to be ignored and it's taking...

How do I combine a Combo Box with a Tree in Swing?

For my application, I want a Combo Box that displays its elements when dropped down as a Tree. Problem is, I'm not versed well enough in Swing to know how to go about doing this. At least without ending up writing a new widget from scratch, or something to that effect. How would I do something like this without creating one from scrat...

In Java: How to zip file from byte[] array?

My application is receiving email through SMTP server. There are one or more attachments in the email and email attachment return as byte[] (using sun javamail api). I am trying to zip the attachment files on the fly without writing them to disk first. What is/are possible way to achieve this outcome? ...

GWT - What's a good GUI editor for GWT in Intellij IDEA?

The one that ships with IDEA is nothing more than a GWT project creation tool. Is there a better plugin? Is there a standalone GUI editor for GWT? ...

An editor for a data object in swing, what is the easiest way?

I have a java object with several members. I want to create a small, quick and dirty editor that allows me to set the value of the members in an easy way. I've created a Panel that contains a TextField for every member. I have a setValues() method that will take the value of the TextFields and set them into the object. This method is...

vector drawing canvas in GWT

Are there are decent implementations of a vector graphics canvas in GWT? I would like to be draw arbitrary shapes and have them react to user input (mouse in/out/click/etc). There are wrappers for the HTML canvas, but that feature is not supported in older browsers (read: IE). ...

Java change and move non-standard XML file

I am using a third party application and would like to change one of its files. The file is stored in XML but with an invalid doctype. When I try to read use a it errors out becuase the doctype contains "file:///ReportWiz.dtd" (as shown, with quotes) and I get an exception for cannot find file. Is there a way to tell the docbuilder to i...

Java bytecode specification.

Is there a nice place for learning the JVM bytecode instruction set. The specification perhaps and maybe some tutorials? I ask because I would like to design a toy language and a compiler for it that generates JVM bytecode. Thanks for your knowledge and perhaps googling. ...

log4j with timestamp per log entry

Hi! this is my log output INFO main digestemails - process inbox INFO main digestemails - checking for emails in c:\development\DCMail\email\KN-Source INFO main digestemails - digesting [email protected] INFO main digestemails - extracting attachments INFO main digestemails - no attachments or no attachments su...

Space-Efficient Data Structure for Storing a Word List?

Is there anything better than a Trie for this situation? Storing a list of ~100k English words Needs to use minimal memory Lookups need to be reasonable, but don't have to be lightning fast I'm working with Java, so my first attempt was to just use a Set<String>. However, I'm targeting a mobile device and already running low on memor...