Skip to content

Tag: java

java: run a 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: javadoc says: After the last live

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 …

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 no more headers. This

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 similarly. I’ve added the bean to the palette but the icon displayed is

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 code I

Java: recommended solution for deep cloning/copying an instance

I’m wondering if there is a recommended way of doing deep clone/copy of instance in java. I have 3 solutions in mind, but I can have miss some, and I’d like to have your opinion edit: include Bohzo propositon and refine question: it’s more about deep cloning than shallow cloning. Do it yourself: code the clone by hand properties after