java

Function pointers/delegates in Java?

Hello, for my Java game server I send the Action ID of the packet which basically tells the server what the packet is for. I want to map each Action ID (an integer) to a function. Is there a way of doing this without using a switch? ...

Java 2D game programming - Newbie questions

Hi, We're a team of a programmer and a designer and we want to make a medium-sized java game which will be played as an applet in the web browser. Me (the programmer) has 3 years of general development experience, but I haven't done any game programming before. We're assuming that: We'll decide on a plot, storyline of the game, etc....

Automatically size JPanel inside JFrame

I have a JPanel subclass on which I add buutons, labels, tables, etc. To show on screen it I use JFrame: MainPanel mainPanel = new MainPanel(); //JPanel subclass JFrame mainFrame = new JFrame(); mainFrame.setTitle("main window title"); mainFrame.getContentPane().add(mainPanel); mainFrame.setLocation(100, 100); mainFrame.pack(); mainFra...

Add a dependency in Maven

How do I take a jar file that I have and add it to the dependency system in maven 2? I will be the maintainer of this dependency and my code needs this jar in the class path so that it will compile. ...

Which to choose: 2D or 3D for a java game

What should a small team choose for their first game, when they are low on time but have big ambitions? I'm an experienced programmer, but haven't done any game programming before this. My designer is very talented and artistic, he has worked with 3D about an year ago but hasn't done it since so it could take him some time to learn it ag...

creating unit tests (semi-)automatically?

Is there a framework that supports generating some standard unit tests from annotations? An example of what I have in mind would be: @HasPublicDefaultConstructor public class Foo { } This would obviously be used to automatically generate a unit test that checks whether Foo has a default constructor. Am I the only person who thought o...

Hibernate: Mapping User-Friends relation in Social Networks

It's quite some time that I'm trying to figure out this problem and from googling around many people have similar problems. I'm trying to model a User in a Social Network, using Hibernate, and what is more basic to a social network than to map a friendship relation? Every user in the system should have a list of it's friends and I thoug...

Java connection to / between Microsoft Windows Office Suite?

I read elsewhere (a response by "hazzen" here) that .NET has "a binding for the entire Office suite outlined here that allows you to write COM-based methods that you can call from Office. It is intended for automation, but you can write any managed code you want and have Excel call into it." I'm interested in the same thing for Java. My...

How to programatically 'login' a user based on 'remember me' cookie when using j2ee container authentication?

i'm using form based authntication in my WAR. i want to implement a 'remember me' cookie so: 1) how can i intercept the authentication before user is redirected to the form? 2) say i checked the cookie and its fine, how do i actually login the user? ...

Simpler-than-JBoss way to have POJO RPC in Java with container session management

Currently, I only know a way of doing RPC for POJOs in Java, and is with the very complex EJB/JBoss solution. Is there any better way of providing a similar functionality with a thiner layer (within or without a Java EE container), using RMI or something that can serialize and send full blown objects over the wire? I'm not currently i...

Should I be using PreparedStatements for all my database inserts in Java?

What is the recommended method for escaping variables before inserting them into the database in Java? As I understand, I can use PreparedStatement.setString() to escape the data, but PreparedStatement seems somewhat impractical if I don't plan to run the same query ever again.. Is there a better way to do it without preparing every que...

Best data binding solution for GWT

Have you ever used one of the many half-baked data binding solutions for GWT? If so, how well did it work? I'd like to stop rolling my own bindings for GWT but there's no clear winner in the data binding space. I'd prefer to use something with a future e.g. GWT Incubator but there's nothing there yet. I use GWTDesigner and love it but...

Changing the Contents of the JComboBox

I would like to change the contents of the list of a JComboBox (like adding another list in place of and older one). Is there any way I might be able to do that? Thanks in advance! ...

How to make the Java.awt.Robot type unicode characters? (Is it possible?)

We have a user provided string that may contain unicode characters, and we want the robot to type that string. How do you convert a string into keyCodes that the robot will use? How do you do it so it is also java version independant (1.3 -> 1.6)? What we have working for "ascii" chars is //char c = nextChar(); //char c = 'a'; // this...

I'd like to learn Struts.Is there any good web sites or books?

I want learn it for abc. And I'd like to know what's the difference between struts 1 and struts 2. ...

Is Grails worth it?

This is half rant, half question. Is it worth using Grails? I'm trying to develop a relatively simple database drive web applications. My expertise is in Java so naturally Grails seemed like a good choice. At first I thought of using Spring, JPA and Hibernate, but having used that previously I've ran into all sorts of tedious configurat...

When to use pointers and when not to?

I'm used to doing Java programming, where you never really have to think about pointers when programming. However, at the moment I'm writing a program in C++. When making classes that have members of other classes, when should I use pointers and when should I not? For example, when would I want to do this: class Foo { Bar b; } As ...

Java based Webmail solutions

I need to provide email sending and receiving capabilities within my java web-application. Think of it as providing a lightweight IMAP client embedded within the application. Are there any good java based open-source libraries/projects/webmail solutions that provide similar functionality? Please note that I don't want to emails would...

Is there something like python's interactive REPL mode, but for Java?

Is there something like python's interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, and immediately get results, without all this public static void nightmare() thing? Thanks ...

How to design interface for a game in Java

We're a team of a designer and a programmer. Me, the programmer, is hopeless on design of all sorts, so the user interface of the game must be created by the designer. We were thinking of a main screen, where the character walks around, a small minimap in the top, an inventory section, etc. All these things would have to be designed in ...