r1254 - in jaxx/trunk/jaxx-runtime-swing: . src/main/java/jaxx/runtime/swing
Author: tchemit Date: 2009-03-03 16:38:17 +0000 (Tue, 03 Mar 2009) New Revision: 1254 Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java Log: in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt =================================================================== --- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-03 07:50:33 UTC (rev 1253) +++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-03 16:38:17 UTC (rev 1254) @@ -1,4 +1,5 @@ 1.3 ?? 200903?? + * 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon * 20090301 [chemit] - add usefull methods in JAXXButtonGroup 1.2 letellier 2009022? Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java =================================================================== --- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-03 07:50:33 UTC (rev 1253) +++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-03 16:38:17 UTC (rev 1254) @@ -51,6 +51,15 @@ * Internal state to known when we can accept click */ protected boolean canClick; + /** + * A flag to enable or disable the use of the icon. + * + * If set to false, no icon will be displayed and no action + * will be possible. + * + * By default, this is active. + */ + protected boolean useIcon = true; public void setAcceptAction(Action acceptAction) { this.acceptAction = acceptAction; @@ -89,12 +98,17 @@ return canClick; } + public void setUseIcon(boolean useIcon) { + this.useIcon = useIcon; + } + @Override public BlockingLayerUI clone() { BlockingLayerUI clone = new BlockingLayerUI(); clone.acceptAction = acceptAction; clone.acceptIcon = acceptIcon; clone.blockIcon = blockIcon; + clone.useIcon = useIcon; clone.setCanClick(false); return clone; } @@ -106,25 +120,28 @@ @Override protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) { - updateCanClickState(l, e); + if (useIcon) { + updateCanClickState(l, e); + } e.consume(); } @Override protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) { - - switch (e.getID()) { - case MouseEvent.MOUSE_ENTERED: - updateCanClickState(l, e); - break; - case MouseEvent.MOUSE_EXITED: - setCanClick(false); - break; - case MouseEvent.MOUSE_CLICKED: - if (canClick) { - acceptEvent(e, l); - } - break; + if (useIcon) { + switch (e.getID()) { + case MouseEvent.MOUSE_ENTERED: + updateCanClickState(l, e); + break; + case MouseEvent.MOUSE_EXITED: + setCanClick(false); + break; + case MouseEvent.MOUSE_CLICKED: + if (canClick) { + acceptEvent(e, l); + } + break; + } } e.consume(); } @@ -132,7 +149,7 @@ @Override protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { super.paintLayer(g2, l); - if (getCurrentIcon() != null) { + if (useIcon && getCurrentIcon() != null) { g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null); } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org