96 } 97 } 98 } 99 100 return retval; 101 } 102 103 private static boolean areScreenDevicesIndependent(GraphicsDevice[] gds) { 104 for (int i = 0; i < gds.length; i++) { 105 Rectangle bounds = gds[i].getDefaultConfiguration().getBounds(); 106 if (bounds.x != 0 || bounds.y != 0) { 107 return false; 108 } 109 } 110 return true; 111 } 112 113 /** 114 * Returns the number of buttons on the mouse. 115 * On systems without a mouse, returns <code>-1</code>. 116 * 117 * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true 118 * @return number of buttons on the mouse 119 * @since 1.5 120 */ 121 public static int getNumberOfButtons() throws HeadlessException { 122 if (GraphicsEnvironment.isHeadless()) { 123 throw new HeadlessException(); 124 } 125 Object prop = Toolkit.getDefaultToolkit(). 126 getDesktopProperty("awt.mouse.numButtons"); 127 if (prop instanceof Integer) { 128 return ((Integer)prop).intValue(); 129 } 130 131 // This should never happen. 132 assert false : "awt.mouse.numButtons is not an integer property"; 133 return 0; 134 } 135 136 } | 96 } 97 } 98 } 99 100 return retval; 101 } 102 103 private static boolean areScreenDevicesIndependent(GraphicsDevice[] gds) { 104 for (int i = 0; i < gds.length; i++) { 105 Rectangle bounds = gds[i].getDefaultConfiguration().getBounds(); 106 if (bounds.x != 0 || bounds.y != 0) { 107 return false; 108 } 109 } 110 return true; 111 } 112 113 /** 114 * Returns the number of buttons on the mouse. 115 * On systems without a mouse, returns <code>-1</code>. 116 * The number of buttons is obtained from the AWT Toolkit 117 * by requesting the {@code "awt.mouse.numButtons"} desktop property 118 * which is set by the underlying native platform. 119 * 120 * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true 121 * @return number of buttons on the mouse 122 * @see Toolkit#getDesktopProperty 123 * @since 1.5 124 */ 125 public static int getNumberOfButtons() throws HeadlessException { 126 if (GraphicsEnvironment.isHeadless()) { 127 throw new HeadlessException(); 128 } 129 Object prop = Toolkit.getDefaultToolkit(). 130 getDesktopProperty("awt.mouse.numButtons"); 131 if (prop instanceof Integer) { 132 return ((Integer)prop).intValue(); 133 } 134 135 // This should never happen. 136 assert false : "awt.mouse.numButtons is not an integer property"; 137 return 0; 138 } 139 140 } |