• R/O
  • SSH

JdbcAcsess2: Commit

全てを再実装したJdbcAcsessです。


Commit MetaInfo

Revision45db3cb8b39fef5583bfa815f09c0b3607206da4 (tree)
Time2012-03-03 21:58:07
Authorshimakazuro
Commitershimakazuro

Log Message

mousewheelでfont変更

Change Summary

Incremental Difference

diff -r f27c15389a60 -r 45db3cb8b39f src/jdbcacsess2/main/FontZoomByMouseWheel.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdbcacsess2/main/FontZoomByMouseWheel.java Sat Mar 03 21:58:07 2012 +0900
@@ -0,0 +1,84 @@
1+/*
2+ * Copyright 2012 Kazuhiro Shimada
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+package jdbcacsess2.main;
18+
19+import java.awt.Component;
20+import java.awt.Font;
21+import java.awt.event.KeyEvent;
22+import java.awt.event.KeyListener;
23+import java.awt.event.MouseWheelEvent;
24+import java.awt.event.MouseWheelListener;
25+
26+/**
27+ * @author sima
28+ *
29+ */
30+public class FontZoomByMouseWheel {
31+
32+ private final Component component;
33+
34+ public FontZoomByMouseWheel(Component c) {
35+ this.component = c;
36+ component.addKeyListener(new KeyListener() {
37+
38+ @Override
39+ public void keyPressed(KeyEvent e) {
40+ if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
41+ component.addMouseWheelListener(mouseWheelListener);
42+ }
43+ }
44+
45+ @Override
46+ public void keyReleased(KeyEvent e) {
47+ if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
48+ component.removeMouseWheelListener(mouseWheelListener);
49+ }
50+ }
51+
52+ @Override
53+ public void keyTyped(KeyEvent e) {
54+ }
55+
56+ });
57+
58+ }
59+
60+ private final MouseWheelListener mouseWheelListener = new MouseWheelListener() {
61+
62+ /*
63+ * (非 Javadoc)
64+ *
65+ * @see
66+ * java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.
67+ * MouseWheelEvent)
68+ */
69+ @Override
70+ public void mouseWheelMoved(MouseWheelEvent e) {
71+ if (!e.isControlDown()) {
72+ return;
73+ }
74+
75+ Font font = component.getFont();
76+ float size = font.getSize() + e.getWheelRotation();
77+
78+ component.setFont(font.deriveFont(size));
79+
80+ e.consume();
81+ }
82+ };
83+
84+}
Show on old repository browser