java

Detecting keyboard direction keys using keyPressed

G'day all, After learning on here that the Java console doesn't support keyboard input a great deal, I switched to Swing and AWT. My problem now is how to detect when the keyboard direction keys (non-numeric keypad) are used. My code (below) does not do more than print a "small box" character when pressing the down, up, left, right key...

How to create a sidebar panel in OpenOffice?

I want to create an OpenOffice.org plug-in that adds a sidebar. I have successfully installed OpenOffice.org, OpenOffice.org SDK and NetBeans OpenOffice plug-in. I am familiar with Java, AWT and Swing, so no need to explain these concepts to me. Now, I want to create a sidebar Panel(or JPanel) in OpenOffice.org Writer application. How ...

Howto print java class garbage collection events ?

Hello, java version "1.5.0_14" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03) Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode) I'm trying to debug a NullPointerException I'm getting for passing a reference to statically defined field. To be more specific, I'm setting a global on a Drools3 working mem...

Why use Mono?

What are the main benefits of using Mono over Java (or any other "free" or Linux-friendly language/runtime)? Mono will always trail behind the latest developments in the .NET framework, why would you want to use Mono over another traditional open-source language/framework (Java)? EDIT: Like someone mentioned below, I guess the root que...

Experiencing >1 second pauses using UseConcMarkSweepGC - help!

Hi, I'm running a memory intensive app on a machine with 16Gb of RAM, and an 8-core processor, and Java 1.6 all running on CentOS release 5.2 (Final). Exact JVM details are: java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode) I'm launching the app...

Why does this applet have a destroy method?

I've been trying to learn about applets by studying the code for the "Welcome to HotJava" applet. I decompiled the *.class file using the Windows version of Jad, and I see the following lines of code public void init() { // Skip some lines... addMouseListener(this); } public void destroy() { removeMouseListener(this); } I...

What's the equivalent C# method to this basic Java method?

Hi folks, really simple question here (more to confirm my thoughts, than anything)... Java method : [StringBuffer.Delete]1; [1]: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html#delete(int, int) Java Code: sb.delete(sb.length()-2, sb.length()); C# (not sure if this is right): StringBuilder sb = new StringBuild...

synchronized block vs synchronized method?

Can any one tell me the advantage of synchronized method over synchronized block with an example?Thanks. ...

can't get the classpath right

i'm trying to compile this slick2d example (first one) but i can't get it to work. here's the code: import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; /** * @author panos */ public class Wizar...

How to show source line numbers in jstack output ?

This is a jstack output from a running JVM "FooThread" prio=10 tid=0x00007f159c2ca000 nid=0x6e21 waiting on condition ..snipped java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at com.myco.impl.QueueFooThread.run(Unknown Source) I want the line number in QueueFooThread to show up l...

Difficulty removing all components from a Jpanel

G'day all, I am coding a main menu for a project. The menu displays properly. I have also set up ActionListeners for the three buttons on the menu. What I wish to do is reuse the JPanel for a new set of radio buttons when the user chooses "Start a New Game". However, coding ActionPerformed to remove the existing components from the...

Coding tip - intersection types and java enums

Intersection types allow you to (kinda sorta) do enums that have an inheritance hierarchy. You can't inherit implementation, but you can delegate it to a helper class. enum Foo1 implements Bar {} enum Foo2 implements Bar {} class HelperClass { static <T extends Enum<T> & Bar> void fooBar(T the enum) {} } This is useful when you ha...

Object construction from serialization - which is preferred?

Lets say you have a class SomeClass which has its own implementation of toString(), and also has the ability to parse a new instance of itself by reading that same string. Which of these methods do you prefer, or find better to use? You can either define it as another constructor: public SomeClass(String serializedString); or you can...

How can I create an executable jar with dependencies using Maven?

I have written a little utility to run from the commandline. I want to package it in a single executable jar for distribution. How can I make maven package all dependend jars into my jar? ...

How to programatically send input to a java app running in a browser window?

Consider the most excellent wordle tag cloud generator: http://www.wordle.net/create Entering text into the "textform" textarea and clicking the go button starts up the wordle java applet on that page. No traffic goes back to the server. How can I cause this to happen programmatically? No hack too cheap!! background for this ques...

read file in an applet

Hi there I want to read out a file that lies on the server. I get the path to the file by a parameter <PARAM name=fileToRead value="http://someserver.de/file.txt"&gt; when I now start the applet following error occurs Caused by: java.lang.IllegalArgumentException: URI scheme is not "file" Can someone give me a hint? BufferedReader ...

Common format for time zone in Java/J2me

We are developing a j2me app for syncing contacts to/from a server. we are storing the update and create time (long mill sec) with each contact for conflict resolution/sync calculations. Now as the client and server app can be in different time zones , how one can store time with time zone in a standard format (to take care diff time zo...

Best IDE for developing Java Desktop Applications

I've been developing Java Web apps using Eclipse as the IDE. Planning to start developing a desktop app based on Java. Can someone suggest the best IDE for developing Java based desktop apps? (One that would have drag drop for building the interface like Visual Studio) ...

Java newbie: inheritance and where to declare an intended universal object

G'day all, I have a Player class, which inherits from an ArmedHumanoids class, which inherits in turn from a Humanoids class. Where and when should I create the Player object so that it is accessible in all my other classes - for example, a selectPlayerRace class? I know that by extending the Player class it becomes accessible, but I...

Singleton servlet?

If I declare a singleton servlet like public static class SomeServlet extends HttpServlet {..... It gives the error indicating that modifier static not allowed here in NetBeans. Please let me know how to create a singleton servlet which allows only one client at a time to execute. Thanks in Advance, Mahes ...