java

using Swing components in javafx if they're not in the NetBeans javafx palette

I'm just getting started with javafx in NetBeans, and I have it doing simple stuff (windows with buttons + the like) but would like to try something slightly more realistic. The "Swing/AWT Components" palette has a whole bunch of stuff that the "JavaFX Script Code Clips" palette does not (it has Button, CheckBox, ComboBox, ComboBoxItem,...

What is serialization in Java?

I've made a small RSS Reader app using Swing and Eclipse keeps telling me "The serializable class MochaRSSView does not declare a static final serialVersionUID field of type long" What is serialization and what benefits would it have? ...

Why is my simple comparator broken?

I have a class, which I have simplified to this: final class Thing { private final int value; public Thing(int value) { this.value = value; } public int getValue() { return value; } @Override public String toString() { return Integer.toString(value); } } I want to sort an array of th...

java += question

Why does: public class Addition { public static void main() { int a = 0; double b = 1.0; a = a + b; System.out.println(a); } } not compile but: public class Addition { public static void main() { int a = 0; double b = 1.0; a += b; System.out.println(a); } } compiles. ...

Need Help Determining Poker Hand (One Pair)

This is just part of the code, so never mind if you can't see the arrays or anything else. The idea is that I have 5 cards and I want to determine which ones are pairs. Does anyone understand what I mean? boolean IsOnePair=true; int [] cont = new int [6]; for (int i=0;i<Game.length;i++) { cont[Game[i].getValue()] ++; } for (int i...

Hibernate: Is there a way to programatically create new tables that resemble an existing one?

I have a web app that have many tables (each represents a POJO). I wrote mapping files for each class and then use Hibernate's SchemaExport to generate the tables in my database. Now I want to create 2 additional tables for each existing table that was created: User permission table - stores user permissions on the POJO specific to ea...

Bouncing Ball in Java

This is probably a really basic problem but I can't seem to find any other articles on it. Anyway, I have written a small bouncing ball program in Java to try and expand my basic skills. The program is just a simple bouncing ball that will drop and hopefully bounce for a while. The original program worked fine but now I have tried to ad...

Download files from a directory listing.

Is it possible to download all the files from a directory listing? Eg., the following link leads to a listing. http://www.arthika.net/1234TB/new/Kuruvi/ Please point me to some related API's to download all the files from such listings (if possible). Thanks ...

Window ID from Java SWT

I would like to find the window ID of my SWT program. I start up my SWT shell in the standard way. How do I then find the ID of the window that's been created? The program is executing on Fedora 10 using the Compiz-Fusion window manager (if that makes a difference). Code to help explain what I mean: public static void main(String[] ar...

differentiate a HTTP Request submitted from a HTML form and a HTTP Request submitted from user

I had written java code for information sent and received for the server in bytes.The issues is how do i differentiate a HTTP Request submitted from a HTML form and a HTTP Request submitted from user. we are trying through refer in HTTP headers, but for the first request the referrer is null. hence this option is not feasible. is there a...

Java exception handling idioms ... who's right and how to handle it?

I currently have a technical point of difference with an acquaintance. In a nutshell, it's the difference between these two basic styles of Java exception handling: Option 1 (mine): try { ... } catch (OneKindOfException) { ... } catch (AnotherKind) { ... } catch (AThirdKind) { ... } Option 2 (his): try { ... } catch (AppException e)...

In hibernate statistics whats the difference between load and fetch

Im mainly looking at the EntityStatics (http://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/EntityStatistics.html). I can see a lot of fetch, loads and updates and i cant find anywhere that says what the difference between them are. ...

What would be the light way to render a JSP page without an App/Web Server

First, some background: I will have to work on code for a JSP that will demand a lot of code fixing and testing. This JSP will receive a structure of given objects, and render it according to a couple of rules. What I would like to do, is to write a "Test Server" that would read some mock data out of a fixtures file, and mock those obj...

Java voice recognition

Is there Anyone that has experience with any open source, or relatively cheap voice recognition API for java? I'm pretty much looking for something that will turn spoken words into text. From the java speech recognition page on sun, it seems that it is something that is rather dead. My requirements is something that at the least runs on...

creating final variables inside a loop

is this allowed in java: for(int i=0;i<5;i++){ final int myFinalVariable = i; } The keyword of my question is final. Is it allowed to do a final variable that changes with every run of the loop? I was wondering this because final says that you can't change the value of the variable (calling only myFinalVariable = i), but i'm redefin...

How to convert AutocadDWG To PDF?

Is there another way to convert AutocadDWG To PDF but to use third party programs? Thanks for any suggestions. ...

Need sample Java code to run a shellscript

Hi, I tried with many different examples, but it is not working. I would really appreciate some sample Java code to run a shell script. ...

Importing Liferay portlet into Eclipse IDE

Hi, I have a question regarding the development of liferay portlets using the liferay plugin SDK. My question goes mainly in the setup of the development IDE. The suggested one would be to use Netbeans IDE which I also tried out, but it appears to run very slowly on my machine while Eclipse is quite performant. The setup for Netbeans ID...

Performance of ThreadLocal variable

How much is read from ThreadLocal variable slower than from regular field? More concretely is simple object creation faster or slower than access to ThreadLocal variable? I assume that it is fast enough so that having ThreadLocal<MessageDigest> instance is much faster then creating instance of MessageDigest every time. But does that al...

Java binding JTextField -> java.lang.Integer problem

I have a text field which is bound with Integer variable, so when user enters number into this field, binding mechanism automatically converts text into Integer and sets this value into var. Problem is, since user types text into text field, that binding mechanism is converting only values, and if user types some letters into it, binding...