I’m running Eclipse for Java. I created a DOM version of an XML file. Now I want to change an attribute of an element in the file. I called a method that called a method in the class that controls the DOM, and I got a dialog box saying “JDI Thread Evaluations has encountered a problem. Exception p…
Tag: java
Convert Month String to Integer in Java
Given a month string such as: Is there any core Java or third party library functionality that would allow you to convert this string to the corresponding month number in a locale agnostic way? Answer An alternative to SimpleDateFormat using Joda time:
Android floating view (over other views)
I’ve been messing around with this for a few days now, hopefully someone here can lend me a hand. I have a simple two-column layout, the left side is a navigation bar with buttons, the right side is …
Run a java function after a specific number of seconds
I have a specific function that I want to be executed after 5 seconds. How can I do that in Java? I found javax.swing.timer, but I can’t really understand how to use it. It looks like I’m looking for something way simpler then this class provides. Please add a simple usage example. Answer EDIT: ja…
Problem with Inner Class. Illegal Start of Expression error
I am practicing using inner classes but am having difficulty with a homework question: It is as follows: Create a Swing component class BetterButtons that extends JPanel and has three Jbutton instances labelled “One”, “Two”, and “Three”. In the constructor of BetterButtons,…
How to detect the current display with Java?
I have 2 displays connected, so I can either launch my Java application on the primary or the secondary display. The question is: How can I know which display contains my app window, i.e., is there a way to detect the current display with Java? Answer java.awt.Window is the base class of all top level windows…
How to convert a Hibernate proxy to a real entity object
During a Hibernate Session, I am loading some objects and some of them are loaded as proxies due to lazy loading. It’s all OK and I don’t want to turn lazy loading off. But later I need to send some of the objects (actually one object) to the GWT client via RPC. And it happens that this concrete o…
Add HEADER in HTTP Request in Java
I’m using this following code to send simple HTTP Request : However, as you can see, I don’t send a custom HEADER. What should I add to send a custom HEADER ? Answer When you write The rnrn bit is sending a line-feed/carriage-return to end the line and then another one to indicate that there are n…
Why doesn’t my JavaBean icon display?
I’m using Netbeans 6.7.1 on Windows Vista, I’ve got a JavaBean component that works as it should and this has an associated BeanInfo class where I’ve set Icon 32×32 Color property to a 32×32 gif file located on the classpath. I’ve also set the 16×16 Color property simila…
Delete SMS in Android 1.5
There are many questions about it, no answers are working in my application 🙁 I need to remove SMS from a receiver, even if the user can see it, but it must be removed programmatically. How can I do it? The most suitable I have used was the following, but it doesn’t work 🙁 Answer After refactoring my co…