java

Cannot convert java.awt.image to int[][][]

I've written a class that I use for image processing in my Java program. The class cannot load an image properly, the 'data' field has the format [row][column][a=0,r=1,g=2,b=3]. When I try to load an image, the data is filled with 0s. public class Image { public int[][][] data; public int width; public int height; Image...

Java: link JSlider and JTextfield for float value

what is the best and easiest way to link a JSlider and a JTextField so that if one changes, the other gets updated too, but there is no recursive loop? thanks! ...

How to run SpeakerIdentApp, a MARF example?

I've download the bin files "SpeakerIdentApp-bin-0.3.0-devel-20060226.tar.bz2" in http://sourceforge.net/projects/marf/files/. I've extracted them and thrrought the console I made: java -jar SpeakerIdentApp.jar It happears the help saying how the command must be performed. If I execute java -jar SpeakerIdentApp.jar --stats it works I...

Java: str.replaceAll() not working

I'm trying to cleanse one String from another. before = before.replaceAll(Constants.GENE_START_SEQUENCE, ""); And yet, the following assertion sometimes fails: assert before.indexOf(Constants.GENE_START_SEQUENCE) == -1 : before; This is what the assert spits out: IIAOOOCOAAAOCCIOOOACAIAOACICOOIAIOOICIIOIIOICOICCCOOAOICOCOOIIOOAOAA...

Maven Plugins - how to require a license

I would like to make my plugin require a license to run similar to the maven clover plugin. Is there some utility out there that I can generate licenses with that will also allow me to integrate that into the plugin? I need to do the following steps. Modify the existing plugin to validate the license file Generate the license file on...

Java: Accessing private fields directly from another instance of the same class

I'm writing a equals(Object obj) function for a class. I see that it is possible to access the private fields of obj from the caller. So instead of using a getter: Odp other = (Odp) obj; if (! other.getCollection().contains(ftw)) { } I can just access the field directly: Odp other = (Odp) obj; if (! other.collection.contains(ftw)) {...

HTML Parsing/Scraping Algorithm Help..Java

I am writing a program that an HTML scraper that when it grabs the HTML from the page, it returns the HTML, and I want to Grab words that are All Capital letters, and then stores these words into a database. My problem right now is I cannot right the algorithm to parse each line of the HTML I got back in order to store the words. This is...

Getting all the values of a array of Strings in one String

if I have, String[] s = new String[3]; s[0] = "Ap"; s[1] = "p"; s[2] = "le"; String result = ? If I want to get Apple out of s without looping, how do I do that? Any short cut? ...

Having issues decompiling *any* class with Jode

I've been staring at this issue for hours now. Any help is appreciated. I wrote code that uses the Jode decompiler from the "embedded jode jar file". I want to use this version because it is under the Lesser GNU Public License. Decompiler d = new Decompiler(); try { FileWriter fw = new FileWriter("c:\\jode.txt"); d.setClassP...

Code analyzers: PMD & FindBugs

1. Regarding PMD: 1.1 How do I set the PMD checks, to ignore some of them, like "Variable name is too short, or too long", "Remove empty constructor, etc" - and if I do that, another warning appears that says the class must have some static methods. Basically, the class was empty, for later development, and I like to leave it that way f...

recommendation for good data visualization books for beginners?

should teach both analysing the data and presentation, with code examples, preferably Java or Ruby. ...

Debugging problems shutting down Apache Tomcat

I have a Tomcat installed as a Windows service, and sometimes it hangs when I try to shut it down (through services.msc). I tried attaching to it with a debugger, but I don't seem to be able to understand why it's hanging. When I try to look at one of the threads by doing "Thread.getThreads()[0]", I get an error from the debugger: "Stac...

Java paste to current cursor position

I want to make simple java program that will insert some text into current cursor position. That cursor position can be in any text editor, for example notepad. Is this possible? ...

Images and Panels

I'm having a problem adding a JPanel on top of an Image. This is what I'm trying to do: Image bgImage = loadImage(filename); JPanel jp = new JPanel(); jp.setBounds(100,100,100,100); jp.setOpaque(true); jp.setBackgroudColor(Color.red); bgImage.add(jp); After doing this, I only see the bgImage. I tried everything but I still can't sho...

Java/Oracle: executing a prepared statement fails on a second iteration of a loop (not all variables bound). Why?

I'm debugging a Java App, which connects to Oracle DB via a thin client. The code looks as follows: (i'm trying to simplify the use case here so pardon me if t does not actually comile) Connection conn = myEnv.getDbConnection(); CallableStatement call = conn.prepareCall( "{ ? = call SomePackage.SomeFunction (?)}"); call.regist...

Absolute keyboard input position (blinking cursor)

Is it possible to make Java program that will determine the absolute position (x,y on screen) of blinking keyboard cursor? That cursor can be in any text editor. ...

What are Upcoming Trends in Software Industry and its Impact for Java Developer ?

Hi, I am writing this post to put up an open ended questions to see What are the upcoming trends in the software industry and what are its impact from a Java/ Java EE Developer point of view ? What technologies are evolving in market place and how java is planning to stay on the top of race on this new era of Software Industry ? An...

Java: Problems with TreeSet

I have a class Odp. I want to use TreeSet to keep a sorted collection of Odp objects. However, I've been having problems. public class OdpStorage { private TreeSet<Odp> collection = new TreeSet<Odp>(); public addOdp(Odp o) { return collection.add(o); } public int size() { return collection.size();...

Java: Always override equals?

When writing one's own classes, is it always necessary to override equals(Object o)? If I don't, will it automatically check that all the fields are the same? Or does it just check if the two variables point to the same object? ...

Java: Treemap - forbid null?

Is there a way to prevent a treemap from accepting null values, or do I need to do a check every time I enter something? ...