Jan 31

Swing is single thread so you are best to load the data from the ResultSet in a separate thread. And because it is a different thread than Swing’s Event Dispatch Thread you’ll need to ensure each entry to be added to the list is added from the EDT.

The SwingWorker class can be used to handle tasks like this.

Let us know if you’d like to see some example code.

written by objects \\ tags: ,

Jan 31

Use the compareTo() method instead of the equals() method.
equals() only considers two BigDecimal’s to be equal if they have same value and scale (eg. 1.25 is not equal to 1.250 when using equals() method).

BigDecimal a = new BigDecimal("1.25");
BigDecimal b = new BigDecimal("1.250");
if (a.compareTo(b)==0)
{
   System.out.println("They are equal");
}

written by objects \\ tags: , ,

Jan 30

The Arrays class includes methods for testing the equality of two array. Two arrays are considered equal if both arrays contain the same number of elements, and all corresponding pairs of elements in the two arrays are equal.

if (Arrays.equals(array1, array2))
{
  // array1 and array2 contain the same elements in the same order
}

written by objects \\ tags: , ,