Hi all.
I'm developing a sim game based on Theme Hospital, which is quite an old game.
I've made lots of progress on the underlying workings, however now I am coming to the GUI elements, which I haven't done alot of before. I am still rather new to java.
The effect I am trying to create is like shown here...
http://www.tubechop.com/watc...
We know that Map interface models function abstraction in math. How should I model multi-variable function? For example, to model f(x, y, z), I have two options:
Map<List<Integer>, Integer> f1;
or
Map<Integer, Map<Integer, Map<Integer, Integer>>> f2;
Which one do you think is better?
Thanks,
...
the code:(the line that will show the compile-error is 3 )
Pair<Manager> managerBuddies = new Pair<Manager>(ceo, cfo);
Pair<? extends Employee> wildcardBuddies = managerBuddies; // OK
wildcardBuddies.setFirst(lowlyEmployee); // compile-time error
the error is about "No corruption is possible"
and what is the type of wildcardBuddies?(...
I'm looking for a simple open source, or reference application that I could use for testing some Java servers. The primary server would be Tomcat, and the database backend is MySQL. Are there some reasonable sample applications out there that are fairly easy to get up and running with?
The ideal application would be fairly stateless in ...
I will be making multiple HTTP calls concurrently and want to allow the user to selectively cancel certain tasks if they take too long. A typical scenario: 1 task pulls twitter feed and another pulls facebook wall posts. The number of tasks is obviously variable, so the idea of a queue comes naturally. I've looked at ExecutorCompletionSe...
What's wrong with the following code?
Object[] a = new Object[1];
Integer b=1;
a[0]=b;
Integer[] c = (Integer[]) a;
The code has the following error at the last line :
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;
...
In situations where two interfaces apply to an object, and there are two overloaded methods that differ only by distinguishing between those interfaces, which method gets called?
In code.
interface Foo {}
interface Bar {}
class Jaz implements Foo, Bar {}
void DoSomething(Foo theObject)
{
System.out.println("Foo");
}
void DoSomet...
I have my program that can draw rectangles. I have two problems I can't solve. After I draw the rectangle it won't stay. The only code I have that clears the canvas in under paint, repaint is only called on mouse drag. Why when I mouse release or mouse move does my canvas clear. The second thing isn't as much a problem, but something I c...
I just tried to use Gears in my GWT application and got following error:
Jul 12, 2009 6:26:29 AM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Jul 12, 2009 6:26:29 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed com.google.apphosting.utils.jetty.DevAppEngineWebAppContext@c45809{/,/Users/work/...
Hi guys.
I have a problem when using Jython, but I can't seem to find a solution in the documentation.
Basically what I have is an object that has been instantiated in Java, and I want to instantiate another Java object (in the python script) and have the pre-instatiated java object added to the object I have instantiated in the jython...
And if so, under what circumstances?
Javadoc and JPA spec says nothing.
...
I'm using ProGuard to obfuscate my code. My project is comprised of a few modules, each obfuscated independently.
One library includes an interface;
public interface IFace {
public int methodA(boolean b) throws CustomException;
}
Another library provides an implmentation
public class IFaceImpl implements IFace {
@Override
...
I'm starting out unit testing and reviewing Java web programming. The thing is I don't know if I'm doing things right.
I'm building a mini blog. I'm using EasyMock for the mock objects.
Here's my code:
The test case
The PostDAO
The Post Bean
I'd really appreciate your comments and suggestions on how I could improve my code and bec...
Emacs and Java change propagation
Hi,
I'm mostly used to code in IDE like Eclipse but I wanted to try emacs. Because I keep hearing about how much better it is than big IDE like Eclipse and Visual Studio.
So I was looking at what emacs provides for Java (with the JDEE extension) but it doesn't seem as complete as Eclipse.
One of the m...
Hi everyone,
I've got a web application with an SQL injection as part of an INSERT statement, it looks like this:
INSERT INTO table1 VALUES ('str1', 1, 'INJECTION HERE')
I can insert the regular multiple-query injections such as ');truncate table1;-- but due to the fact that Java+MySQL is used it does not allow stacking multiple queri...
I have a class with a static member like this:
class C
{
static Map m=new HashMap();
{
... initialize the map with some values ...
}
}
AFAIK, this would consume memory practically to the end of the program. I was wondering, if I could solve it with soft references, like this:
class C
{
static volatile SoftReference<Map> m...
Are there any online resources which show the basic steps to access the Microsoft CRM web service with a client written in Java?
Which web service toolkit should I use?
I tried it with JAXB but there is a conflict in the WSDL element naming which requires a class customization. If I find the correct binding fix, I will post it here.
E...
I want to return an age in years as an int in a Java method.
What I have now is the following where getBirthDate() returns a Date object (with the birth date ;-)):
public int getAge() {
long ageInMillis = new Date().getTime() - getBirthDate().getTime();
Date age = new Date(ageInMillis);
return age.getYear();
}
But since getYear()...
I'm curious. What could be the reason that a Comparator shuffles entries on each
application start?
final static class ContactsListComparator implements Comparator
{
public int compare(Object o1, Object o2)
{
if((o1.toString().compareTo(o2.toString()))<0)
{
return -1;
}
if((o1.toString().compareT...
When importing xml to a DB with Hibernate, is there a way to resolve an attribute consisting of comma-separated values to populate related table(s)?
In this (somewhat obfuscated) example I have an xml file, each row of which represents a Person. The Person has a Hobbies property which contains a comma-separated list of values. The Perso...