Revision: 1100
Author: peterdb
Date: 2006-04-27 12:28:02 -0700 (Thu, 27 Apr 2006)
ViewCVS: http://svn.sourceforge.net/spring-rich-c/?rev=1100&view=rev
Log Message:
-----------
Added Paths:
-----------
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/util/FontSizeAdjuster.java
Added:
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/util/FontSizeAdjuster.java
===================================================================
---
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/util/FontSizeAdjuster.java
(rev 0)
+++
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/util/FontSizeAdjuster.java
2006-04-27 19:28:02 UTC (rev 1100)
@@ -0,0 +1,81 @@
+package org.springframework.richclient.util;
+
+import java.awt.AWTEvent;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.AWTEventListener;
+import java.awt.event.MouseWheelEvent;
+
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.FontUIResource;
+
+public class FontSizeAdjuster {
+ private static final AWTEventListener listener = new AWTEventListener()
{
+ public void eventDispatched(AWTEvent e) {
+ MouseWheelEvent event = (MouseWheelEvent) e;
+ if (event.isControlDown()) {
+ System.out.println("adjust");
+ adjust(event.getWheelRotation() < 0 ? -1 : 1);
+ }
+ }
+ };
+
+ private static int adjustment = 0;
+
+ private FontSizeAdjuster() {
+ // static class only
+ }
+
+ public static void init() {
+ Toolkit.getDefaultToolkit().addAWTEventListener(listener,
+ AWTEvent.MOUSE_WHEEL_EVENT_MASK);
+ }
+
+ public static void dispose() {
+ Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
+ }
+
+ public static void adjust(int amount) {
+ Object[] objs =
UIManager.getLookAndFeel().getDefaults().keySet()
+ .toArray();
+ for (int i = 0; i < objs.length; i++) {
+ if (objs[i].toString().toUpperCase().indexOf("FONT") !=
-1) {
+ Font font = UIManager.getFont(objs[i]);
+ if (font != null) {
+ UIManager.put(objs[i], new
FontUIResource(font
+
.deriveFont((float)font.getSize() + amount)));
+ }
+ }
+ }
+
+ adjustment = adjustment + amount;
+
+ updateUI();
+ }
+
+ public static int getAdjustment() {
+ return adjustment;
+ }
+
+ private static void updateUI() {
+ Frame[] frames = Frame.getFrames();
+ for (int i = 0; i < frames.length; i++) {
+ update(frames[i]);
+ }
+ }
+
+ private static void update(Window window) {
+ SwingUtilities.updateComponentTreeUI(window);
+ window.pack();
+
+ // update the owned windows and dialogs
+ Window[] ownedWindows = window.getOwnedWindows();
+ for (int i = 0; i < ownedWindows.length; i++) {
+ Window childWindow = ownedWindows[i];
+ update(childWindow);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs