java

Calling this from inside a nested Java ActionListener.

Suppose I have this: class external { JFrame myFrame; ... class internal implements ActionListener { public void actionPerformed(ActionEvent e) { ... myFrame.setContentPane(this.createContentPane()); } } ... } createContentPane returns a Container. Now, if I wa...

Java Leaky Abstraction Checker

I am mulling over the idea of writing a program to check for "leaky abstractions" in Java. The one area that popped into mind right away is with exceptions: public class X { // this one is fine, Readers throw IOExceptions so it is // reasonable for the caller to handle it public void parse(final Reader r) throws I...

Reverse iteration through ArrayList gives IndexOutOfBoundsException

When I reverse iterate over an ArrayList I am getting a IndexOutOfBoundsException. I tried doing forward iteration and there is no problem. I expect and know that there are five elements in the list. The code is below: Collection rtns = absRtnMap.values(); List list = new ArrayList(rtns); Collections.sort(list); for(int j=list.size();j...

What event would I need to be able to tell that the mouse was moved over a JMenuItem?

I'd like to handle the case where the mouse goes over any of the JMenuItems. I don't need the user to click one of the JMenuItems; simply to move the mouse over any of them. Basically, he has to click the JMenuBar to show the menus, but he doesn't have to click any menu item. I wanted to use an actionPerformed listener on the JMenuBar -...

How can I stop a Java while loop from eating >50% of my CPU!?

Okay, I tested this on an empty program, and just having a while(true){} running gave me >50% on my CPU. I have a game I'm working on that uses a while loop as it's main loop, and it's CPU is at 100 all the time. How can I get Java to repeat something over and over without eating up >50% of my CPU just to do the repeating? ...

How to embed a mini-console within a Java app?

Hey all, I'm making a small game in Java and would like to add a Quake 3 style of console to the game, that supposed to appear when toggled. Is there any implementation or any similar embedded console you folks know of? Otherwise, what would be a good way to go about it? Right now, I simply have a TextArea on top of a TextField. J...

What is the most popular web programming language?

I have seen various statistics on language popularity based on search engine results, number of books published, open source projects developed, etc. but none of them is specific for web development (on the server side). Almost all of them shows Java, C and C++ as the most popular. I wonder how PHP, which was created explicitly for web d...

Android Convert Video To MP4

I have a Android app. It recieves videos in .flv format which is unplayable by the Android phone. I was wondering how to convert the file to MP4. I could use FFMPEG, but I do not know how I would get it onto the phone, and how it would work on multiple phones if it was compiled for a single one. ...

.NET, Java to JavaScript compiler

I am interested to create a drag-and-drop layout designer using only JavaScript, HTML and CSS. The designer will allow the user to drag the page elements from one place to another (something like Blogger's layout designer) to create a site layout. But I don't want to hand code everything in JavaScript, I would prefer to write my applicat...

NoElementException but I print the element and get the expected result

What I am trying to do is save a Move objects into a Vector called topMoves. There will be many Move objects which is why I create the object within the loop. The pastPriceMap stores prices for stocks at some past time (in this case one minute ago). The currPriceMap stores price for stocks some time within the last second. I get the fo...

How do I "log in" to a web app and access subsequent pages using Java?

I want to write a Java program that'll access a few web pages that requires logging in. How would I keep the session cookie resulting from logging in so I can access those pages? ...

Best practice to specify external directory for storing images in Tomcat?

Best practice to specify external directory for storing images in Tomcat? ...

Validation Framework in Java

We are currently in the process of refactoring our plugin API**(JDK 1.4 compliant)** which is shipped to our clients in the form of a jar file(ie, no need to have javascripts to be generated and so forth). This is a very lightweight plugin so that we have kept away as many dependent jars as possible like Spring. During this process we st...

Java int... array notation

I've seen this before in a method parameter, and it appears to allow an arbitrary number of parameters to be stuffed in an array created at run-time. What's the official name of this language feature? Thanks! public static void trace(View view, RecyclerTraceType type, int... parameters) { RecyclerTrace trace = new RecyclerTrace...

adding classpath in linux

Hi, export CLASSPATH=.;../somejar.jar;../mysql-connector-java-5.1.6-bin.jar java -Xmx500m folder.subfolder../dit1/some.xml cd .. is the above statement for setting the classpath to already existing classpath in linux is correct or not ...

problem while importing the data from text to mysql

Hi, I have used an application to import some data from a text file to mysql. I have used the following code. try { stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); stmt1= (Statement) conn.createStatement(); int deleteRows = stmt1.executeUpdate("delete fro...

How do you get the "object reference" of an object in java when toString() and hashCode() have been overridden?

I would like to print the "object reference" of an object in Java for debugging purposes. I.e. to make sure that the object is the same (or different) depending on the situation. The problem is that the class in question inherits from another class, which has overriden both toString() and hashCode() which would usually give me the id. ...

How do I use a base class or interface with a grid or loop component in Tapestry 5?

I have a concrete class A that extends BaseA and implements InterfaceA. I want to loop through a list of A using either the base class or interface as the looping variable. Trying something like this: <t:loop source="listOfA" value="propertyOfTypeBaseA"> ${propertyOfTypeBaseA.someField} </t:loop> gives me an error "Could not fin...

Why do applets have such a low adoption level?

Why do applets have such a low adoption level, compared for example against Flash? Is it because they are technological disadvantages, or is it just an issue of popularity? ...

tinting sprites in Java2D on the fly?

I am creating a game with an ascii-like map using Java2D on Linux (like a roguelike). By rendering BufferedImages via Graphics2D.drawImage the terrain is rendered. I would like to change the hue of each drawn image on the fly, without hurting performance too much. How can I achieve this? I suspect setComposite is part of the puzzle. C...