java

spring and interfaces

I read all over the place about how Spring encourages you to use interfaces in your code. I don't see it. There is no notion of interface in your spring xml configuration. What part of Spring actually encourages you to use interfaces (other than the docs)? ...

Where to get more information on Dictionary ADT and Skip List for Java?

I'm trying to go deep into Dictionary ADT and Skip List for Java. My textbook doesn't cover a lot about this and whatever it has covered is very complicated. Which is the best online site to get more information on Dictionary ADT and Skip List for Java. I'm looking for the one which talks visually and gives a lot of examples. ...

JTextArea in vi mode

Is there a free and open source extension of JTextArea that would support "vi mode"? ...

Is there a performance difference between a for loop and a for-each loop?

What, if any, is the performance difference between the following two loops? for(Object o: objectArrayList){ o.DoSomthing(); } and for(int i=0; i<objectArrayList.size(); i++){ objectArrayList.get(i).DoSomthing(); } ...

How to go about web service security in Java

Does anyone have a recommendation about web service security architecture in Java (preferably under JBoss)? Any recommended reading? I want to expose a fairly rich web service to the world but the data are sensitive and it requires authentication from the current client (Flex), accessed via RPC. I definitely do not want any server-sid...

JSTL forEach tag: problems with enumeration, and with understanding how it should work

Hello, I've experienced rather strange behavior of JSTL forEach tag. I have some bean called SessionBean: public class SessionBean { private Collection<MyObject> objects; public Collection<MyObject> getObjects() {return objects;} ... } And a simple JSP page like that: <%@page contentType="text/html"%> <%@page pageEncoding="UTF...

getUrl using Java

Is there a way of getting the websites absolute URL (http://www.domain.com/) using Java? because I've googled a bit but I only come across with having to make 2 or 3 classes to create that function =/ Thanks ...

Using Stream Result with Struts2

I am attempting to use a Stream Result to return an image from a struts2 application. I seem to be having problem with configuring the action. Here is the configuration: <result name="success" type="stream"> <param name="contentType">image/jpeg</param> <param name="inputName">inputStream</param> <...

Best Web applications framework for Java?

Which is the best framework for Java? I'm looking for something similar to Symfony for php and Ruby-On-Rails for Ruby? I even don't know if anything such exists for Java or not. ...

How do I have multiple components respond to a single event in JSF?

Here's the sit: I have a JSF component which is basically a list of 'documents' I have any number of document viewer components on the same page. None of these components "know" about each other. In other words, they cannot be configured at design time to link to each other or anything like that. When the user clicks a document link ...

Java equivelent to pyftpdlib?

Is there a good Java alternative to pyftpdlib? I am looking for an easy to setup and run embedded ftp server. ...

Creating a transparent panel

I need to create a panel which should be invisible but the components inside it (for example, JTextArea, JButton, etc.) should be visible. When I click on the invisible panel, it should become visible. I can only use JRE 1.4 and nothing more than that. :( Any idea how to create such a transparent panel??? ...

Unable to change font in java.awt.MenuBar

I'm trying to change the font in an AWT menu bar using MenuBar.setFont(). The call works for the menu bar's child menus, but the menu bar itself doesn't change font (I'm trying to make the font larger). Does anyone know whether this is possible to do? I'm using JRE 1.6 on Windows XP. Update: Changing the font does seem to work so long...

How to close a java swing application from the code

What is the proper way to terminate a Swing application from the code, and what are the pitfalls? I'd tried to close my application automatically after a timer fires. But just calling dispose() on the JFrame didn't do the trick - the window vanished but the application did not terminate. However when closing the window with the close bu...

What is the memory consumption of an object in Java?

Is the memory space consumed by one object with 100 attributes the same as that of 100 objects, with one attribute each? How much memory is allocated for an object? How much additional space is used when adding an attribute? ...

Validating a Postscript without trying to print it?

Saving data to Postscript in my app results in a Postscript file which I can view without issues in GhostView, but when I try to print it, the printer isn't able to print it because it seems to be invalid. Is there a way to validate / find errors in Postscript files without actually sending it to a printer? Preferred would be some kind ...

Is a Java interface an abstract class?

I'm working through some homework and a question on a previous exam paper asks to name all of the abstract classes in a given UML diagram. Fairly straightforward, I suppose. There is one abstract class and three interfaces. Do these interfaces qualify as abstract classes, in general? ...

What is the difference between a Functor and the Command pattern?

I am very familiar with the Command pattern, but I don't yet understand the difference in theory between a Functor and a command. In particular, I am thinking of Java implementations. Both are basically programming "verbs" represented as objects. However, in the case of functors, as I have seen from some examples anonymous inner class im...

Calculate the display width of a string in Java

How to calculate the length (in pixels) of a string in Java? Preferable without using Swing. EDIT: I would like to draw the string using the drawString() in Java2D and use the length for word wrapping. ...

Type mismatch with generics

Here's an interface: public interface Foo<T> extends Comparable<Foo<T>> { ... } And there are some classes implementing this interface: public class Bar extends Something implements Foo<Something> { public Vector<Foo<Bar>> giveBar() { ... } } public class Boo extends SomethingElse implements Foo<SomethingElse> { ...