src/solaris/classes/sun/awt/X11/WindowDimensions.java

Print this page

        

@@ -71,11 +71,11 @@
     }
 
     public WindowDimensions(final WindowDimensions dims) {
         this.loc = new Point(dims.loc);
         this.size = new Dimension(dims.size);
-        this.insets = (dims.insets != null)?((Insets)dims.insets.clone()):new Insets(0, 0, 0, 0);
+        this.insets = cloneOrZero(dims.insets);
         this.isClientSizeSet = dims.isClientSizeSet;
     }
 
     public Rectangle getClientRect() {
         if (isClientSizeSet) {

@@ -114,11 +114,11 @@
     public Dimension getSize() {
         return getBounds().getSize();
     }
 
     public Insets getInsets() {
-        return (Insets)insets.clone();
+        return cloneOrZero(insets);
     }
     public Rectangle getBounds() {
         if (isClientSizeSet) {
             Rectangle res = new Rectangle(loc, size);
             res.width += (insets.left + insets.right);

@@ -175,6 +175,11 @@
     }
 
     public int hashCode() {
         return ((insets == null)? (0):(insets.hashCode())) ^ getClientRect().hashCode() ^ getBounds().hashCode();
     }
+
+    private static Insets cloneOrZero(Insets insets) {
+        return insets == null ? new Insets(0, 0, 0, 0) :
+            (Insets)insets.clone();
+    }
 }