java

How to call setUndecorated() after a frame is made visible?

In my Swing application, I want the ability to switch between decorated and undecorated without recreating the entire frame. However, the API doesn't let me call setUndecorated() after the frame is made visible. Even if i call setVisible(false), isDisplayable() still returns true. The API says the only way to make a frame not-displayabl...

Block level synchronization

What is the significance of parameter passed to synchronized? synchronized ( parameter ) { } to achieve block level synchronization. Somewhere i saw code like class test { public static final int lock =1; ... synchronized(lock){ ... } } I don't understand the purpose of this code. Can anyone give me a be...

Dollar sign in visualvm

I am trying to profile an application and I have a lot of instances of type sim.core.EndPoint$2 When I inspect those instances I verify they are not of type sim.core.EndPoint, they seem to be an EndPoint with a few more things that shouldn't be there. What does a dollar sign mean after the name of a type in visualVM? Thank you. ...

Finding the median of numbers in a LinkedList

How do you find the median of a list of numbers stored as a LinkedList in Java? I don't understand the Selection Algorithm that Wikipedia refers to. Bonus points if you can explain that. ...

Tracking changes in a swing GUI

Say, an application properties page with lots of JCheckboxes, JTextfields, JLists and other JComponents. Now, what I need to do is track the changes user makes and save them. What would be the correct way of implementing this? ...

Java - Is This Good Programming Practice?

Hi folks, Just wondering if the following is considered to be good programming practice or not? I like to keep my individual source files as concise and uncluttered as possible, but I'm wondering what more experienced coders would think of it. I especially like the idea of the Settings.java class to keep all of my "Magic Numbers" in th...

Java client certificates over HTTPS/SSL

I am using Java 6 and am trying to create an HttpsURLConnection against a remote server, using a client certificate. The server is using an selfsigned root certificate, and requires that a password-protected client certificate is presented. I've added the server root certificate and the client certificate to a default java keystore which...

Can someone summarise visibility choices for Java interfaces?

I have two questions really: 1) When would you use a package-private interface? 2) Is there a way to have a public interface which is closed for implementation outside its package? ...

How to implement this equation in Java?

Ok, this is more of a follow-up question: http://stackoverflow.com/questions/874982/how-to-compute-optimal-paths-for-traveling-salesman-bitonic-tour First of all, for the bitonic tour of the traveling salesman problem I have the following recurrence relation: (a) When i = 1 and j = 2, l(i; j) = dist(pi; pj ) (b) When i < j - 1; l(i; j)...

Converting Time/DataTime/Data into java.util.Calendar?

Is it possible in easy way to convert JRuby Time/DataTime/Data into java.util.Calendar including the timezone? On #jruby I was given such code cal.set_time_in_millis(time.to_i) but I lost information about timezone in betwean. So the more specific question is how to convert the timezone but I prefered to ask more broad questin in case t...

Which Java framework to use to write a blogging engine?

Hi, I'm planning to write a blogging engine over the summer to learn about web apps & servlets, etc. What would be an appropriate framework to use? I've been told Spring would be good, but I don't know anything about it. Any suggestions? ...

Log4j Properties in a Custom Place

I'm using Apache Commons Logging and SLF4J with log4j, but I also want to use the log4j.properties in a custom place like conf/log4.properties. Here is the problem: If i use PropertyConfigurator.configure("conf/log4j.properties"); then my app is tied to log4j and defets the purpose of having ACL and SLF4J. What is the best way to ...

Why does Java code generated to perform an operation run more slowly than an "interpreter loop"?

I have some Java code which performs bitwise operations on a BitSet. I have a list of operations and can "interpret" them by looping over them, but it's important to me that I can perform these operations as quickly as possible, so I've been trying to dynamically generate code to apply them. I generate Java source to perform the operat...

Emailer in Java using Strategy Pattern

UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom emailing utility. Now, to obey Single Responsibility Principle, I want to have the following classes: MailerSender, MailProvider and EmailObject. The MailSender is more of a delegate, check it out below: public class MailSender { private IMailPr...

Executing Java 5 Code With Java 6

Is there any way I can run class files (i.e. with main as the entry point) on JDK 6 that were compiled with Java 5? ...

How can I use credit card numbers containing spaces?

Some fancy websites show an error dialog when it is detected that an untrained shopper has entered a credit/debit card number as it is printed on their card with spaces. Is it possible in some way to write a Java web app that handles these numbers with spaces as if they were correct? ...

Hibernate + Swing

What's the best practice? A single session for the whole app A session per window A session per thread, and detaching everything at random Something else? I've googled around, and there's no consensus. Everyone says something, and then takes it back. I find lugging a session around stupid... So, what's the deal? ...

Is Spring ever going to combine MVC and WebFlow?

I thought I read Juergen Holler somewhere once in the past say that a future goal of Spring was to combine Spring MVC and WebFlow... Is this still the case? At the moment they still seem to be fairly separate projects, with WebFlow being recommended as an EXTENSION to MVC. As a developer it would be great if I could use both and defin...

red5 actionscript

Hi all, How to get a parameter encode in the url ? for exemple, if we have an html file containning : how to get the value of a from application.java class ? Thanks ...

Hibernate mapping and inheritance issues with @SecondaryTable

I have a pretty simple class hierarchy structure that is listed below, each sub class having a @DiscriminatorValue enumeration type, which works very well. Abstract class: AbstractNode (abstract class mapped to the Node table) Subclassed classes: FieldNode (simple class mapped to Node table as well, but with different @DiscriminatorV...