java

Redefine the behavior of the Tab key in a JRadioButton?

I'm trying to redefine the behavior of the Tab key in a JRadioButton so it behaves like radio buttons in other GUI applications, that is: Arrow keys cycle through the radio buttons in the ButtonGroup (I have this working) Tab moves focus to the next component after the last radio button in the group (Problem area) I have an Action th...

How to check if a file exists in a war file?

How can I check if a file exists in a war file? I know I can use boolean doesExist = new File(myfile).exists(); but how do I use that in a java class in the war? The file.getAbsolutePath() just shows where the war file is running. I need to check if there is an image in another directory in the war that matchs the filename in the w...

What is proper code pattern to finalize transactions in Java (rollback on exception and commit on success)?

I'm looking for generic code pattern to properly handle transaction with respect to possible exception. I assume there is common code pattern for that, no matter what concrete kind of transaction we are dealing with. I have a method that executes something in transaction and want to rethrow Exception that may occur when inside transacti...

how to use JRadioButton groups with a model

Is there any way to associate a group of JRadioButtons with a data model so it is easier to tell which button (if any) is selected? In an ideal world, I would like to associate a group of N radiobuttons with an enum class that has a NONE value and one value associated with each radiobutton. ...

How to add a JComboBox to a JTable cell?

I am trying to add JComponents to JTable Cells. Do I Implement CellRenderer or CellEditor? ...

JDBC always tests the last row of MySQL table?

Hi, I have a Manager class that saves data in the SQL table and also get result from SQL table and test these data.when I run my program,one frame will be shown that gets ID and password and if they are correct ,the other frame will be shown.BUT I don't know that why it just test the last row of SQL table?? i mean if I set those text fie...

Open-Source Applications using Java JMS?

Does anyone know of open-source applications that are built on top of Java JMS? I am looking to find applications so I can study them and see how they are used. This earlier post has examples of hypothetical uses for JMS, but I am looking for actual code! Thanks, Nels ...

Java applet screen capture to a video

I wanted to find out how can one capture screencast using java. I know that using Robot class one can get a screenshot but how do I go about capturing it as a video and then uploading it to the server? How exactly would that work? ideas? ...

Retaining android app state using alwaysRetainTaskState and lauchMode

In my Android app, I have a main activity that serves as an entry point to my application, which is configured in my manifest file like this : <activity android:name=".Main" android:label="@string/app_name" android:screenOrientation="portrait" android:alwaysRetainTaskState="true" ...

Grant public access to one GAE servlet but use authentication for all other resources?

Hello, for an online bug report web application, I need to find a way how any user can submit a bug report (using HTTP POST) to a Servlet in a Google App Engine application, while all other Servlets (the application admin interface) are protected so that they grant access only to users which have logged in with their Google account. The...

get source jars from maven repository

Hello, Does anyone have any ideea if you can find source jars on maven repositoryes? ...

Issues and gotchas with new POI 3.6 API (XSSF) working with Excel 2007 workbooks

I just started using the new POI 3.6 http://poi.apache.org XSSF which was released in December 2009. The updated API provides support for reading and writing in the OOXML spreadsheet format (.xslx) with Java. So far I've been pretty impressed with the API and haven't really encountered any issues with it. What issues or gotchas have you...

specifying custom properties to a displaytag table decorator

I have a decorator specified on a displaytag table that I need to pass parameters to. The decorator adds an id attribute to the row. Currently the values I require are hardcoded. The parameters I need are: The name of the property to use as id value An id prefix (usually the property used is a number and IE doesn't like ids starting w...

java.net.SocketException: Software caused connection abort: connect

I am trying to programmatically (Java) open a URL that points to a modem on the network. I am connected to the network and can ping the device as well as fetch the URL within a browser. However, programmatically, I get the following stack trace when trying to open the connection. java.net.SocketException: Software caused connection abor...

Regular expression for a valid filename without extension

I need a regular expression pattern to check a string for alphanumeric(a-zA-z0-9) and also can contain underscore, hypen and dot this will be a file name so i dont want other character than this. ...

Network Intrusion Detection System in Java..!!

i am planning to implement a NIDS (netw intrusion detection system) in d java programming language on a very small basis... well after searching i found 2 libraries for it.. 1) Jpcap 2) jNetPcap which one should i use..and y..? which is more preferrable to use...? ...

Ant Task To Copy To Windows Share (SMB)

Is there an ant task (similar to ftp or scp tasks) that would allow me to copy a set of files to a windows (smb) share? Edit: I had to create a task using jcifs for this. If anyone needs it, here is the code. Depends on jcifs and apache ioutils. import java.io.File; import java.io.FileInputStream; import java.io.IOException; import ...

Counting number of Regex query matches in Document field

Hi, Using Lucene, I can figure out how to create a document, put values in respected fields and then proceed to use a searcher to search the indexed document for matches. However, I am now more concerned with the number of matches in a particular field of each document. Just knowing there is a match is fine but I would like to know ho...

Java program with startupparameters in eclipse

I've just started using eclipse and java and I'm not used to either one of them. I wrote a simple helloworld-programm, but the next task (school) was to create a program that takes a userinput (from commandline) and responds with the highest number of two. The code I wrote looks like following: public class Larger { /** * @par...

JPA cascade update problem. Am i doing this the wrong way?

Hi everyone, i'm using JPA on a SWING application in JAVA that connects to an Apache DERBY embedded database. I use Netbeans as my IDE and use many of the "suposedly" helpfull templates. My problem it's simple, but it's dificult for me to explain so i will paste the relevant code here and try to explain at the bottom. @Entity public c...