java

Setting the size of panels

I have 3 panels. One is the main panel which holds 2 smaller panels. For the main panel, I used setPreferredSize(new Dimension(350, 190)); For the smaller left panel, I used setPreferredSize(new Dimension(100, 190)); For the smaller right panel, I used setPreferredSize(new Dimension(250, 190)); but the smaller panels remain t...

Different approaches to dynamic typing in the CLR and JVM

.NET 4.0 introduces new support for dispatching invocations on dynamically typed objects. As far as I can make out, this involves: no change to the CLR new types in the BCL new compilers that convert new syntax into usages of the new types In the Java space, folks are discussing adding a new dynamicinvoke bytecode to the JVM such th...

How to retrieve data which caused unique constraint violation (via Hibernate)?

Hi, Is there a way to find out which record caused such a violation in Hibernate? Normally you add objects to session and at the end you persist them. If such an error occurs it takes a while to track down which record has violated the constraint. Is there way to find out which record caused (either to "toString() in case of new obje...

How to write a downsampling function in Java

I'm trying to write a filtering function for an image, but I can't seem to wrap my head around (or remember) how to transfer all that math theory into code. Lets say I have the following function, where the ints inside the arrays are integers between 0 and 255 (pretty much grayscale pixels to keep it simple). private int[][] resample(i...

JiBXException: Multiple bindings defined for class

Strange thing... I have a binding definition user-wrapper.xml: <binding> <include path="core-wrapper.xml" /> <include path="user-composite-entity.xml" /> <mapping name="users" class="UserWrapper" extends="CoreWrapper"> <structure map-as="CoreWrapper" usage="optional" /> <collection field="users" usage="optional" ...

.war vs .ear file

What is the difference between a .war and .ear file? ...

Mapping Calculated Fields in Hibernate

I'm not sure if this is possible in Hibernate but it would be really great if it was :) I've not actually got past the conceptual stage with this but I'll explain as best as I can. I want to make use of Oracle Spatial features to do proximity based searching. Imagine I've got a Location entity which stores a latitude/longitude value. Th...

in toplink and struts 2 based application, even after commiting data data disappears from the database

I have a struts 2 application and a toplink persistence provider running on tomcat 6.0.20 and a MySql 5.1.38 server on a GNU/Linux machine. After committing the data the when i go to retrieve it the data it has disappeared from the database. I do a em.commit() and em.flush() after my queries have executed. How do they disappear? I am u...

Waiting for mouse input in Java Swing

I'm working on a Java Swing application. I have a button whose action runs a query on a database and then plots the results. These commands are performed from the listener on the Run button. As I understand it, this means that the thread running at this point is from the EventQueue. Given certain input, I need to halt processing an...

What features should Java 7 onwards have to encourage switching from C#?

C# has a good momentum at the moment. What are the features that you would need to have in order to switch (or return) to Java? It would also be quite useful if people posted workarounds for these for the current Java versions, e.g. Nullables being wrapped around custom classes, to make this a much more interesting wiki. ...

what is the right way to use log4j within jsp pages

I mean, I want the logger name to reflect the source.jsp file, no matter if it is included in another file or compiled to a class or whatever. ...

Java: dealing properly with pipes as stdin

I get a weird error ("The process tried to write to a nonexistent pipe.") if I stop reading from piped input, from a program that works fine for non-piped input. How can I avoid causing this error? code: package com.example.test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class...

How can I populate a JFace ContentProposalAdapter from the internet?

So, I'm working on a plugin at work and I've run into a situation where I could use a ContentProposalAdapter to my benefit. Basically, a person will start typing in someone's name and then a list of names matching the current query will be returned in a type-ahead manner (a la Google). So, I created a class IContentProposalProvider which...

Refactoring JSP scriptlet loop to be more readable

I have some JSP code, which writes a tree representing hierachical data. This data is represented using nested layers. In the JSP code there are many code snippets similar to the following code (which outputs as many closing div tags as is the numerical value of variable differenceAmount): <jsp:scriptlet> int differenceAmount = pr...

How to implement automatically select item in a html and click submit ?

I have a website, and username and password, and usually I will login the website with the username and password, and select some items in check boxes and submit them to execute actions. but right now i need to write a application to select the checkbox by some keywords and submit them automatically. Do anyone have good idea ? I used ...

Send file with REST?

Do Java REST frameworks like Restlet and Jersey allow one to send a file as input to a web service? This would encompass the client sending the file and the server then receiving and processing the file. ...

How to Copy the contents with line breaks from a JTable to Excel with line breaks included

Hai I have an application in which I have a JTable with line breaks(pressing Enter key while editing) included in each and every cell.The problem is when I copy the contents from my JTable to Excel I am not getting the contents in same format as in my Jtable(with line breaks) to my excel that is with line breaks.Is there any way to solve...

problem while compiling java code on network drive, it creating class files in lowercase

i am using clear-case source control, i created my vob repository(which has my java source code) on the network drive, when i rum my javac compiler on the source it compiles fine but it is generating class files in lowercase where it should start with uppercase letter. i have seen the code every thing mentioned perfect. then i tried to c...

Gotchas in JDK 6

Are there any gotchas in JDK 6 which did not exist in earlier versions? I am interested in finding out some surprising changes like the following one in the way Timestamp.valueOf() works. Timestamp.valueOf(), when provided with a timestamp which contains a date or a month with a single digit. eg. 2009-9-20, 2009-9-3, 2009-12-4 etc., beh...

Face recognition in Java

Can any one suggest me an open source face recognition framework in Java? ...