comparison src/treeVnc/VncCanvas2.java @ 0:756bfaf731f3

create new repository
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Feb 2012 04:10:12 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:756bfaf731f3
1 package treeVnc;
2 //
3 // Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved.
4 //
5 // This is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This software is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this software; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 // USA.
19 //
20
21 import java.awt.*;
22 import java.io.*;
23
24 //
25 // VncCanvas2 is a special version of VncCanvas which may use Java 2 API.
26 //
27
28 class VncCanvas2 extends VncCanvas {
29
30 /**
31 *
32 */
33 private static final long serialVersionUID = 1L;
34
35 public VncCanvas2(VncViewer v) throws IOException {
36 super(v);
37 disableFocusTraversalKeys();
38 }
39
40 public VncCanvas2(VncViewer v, int maxWidth_, int maxHeight_)
41 throws IOException {
42
43 super(v, maxWidth_, maxHeight_);
44 disableFocusTraversalKeys();
45 }
46
47 public void paintScaledFrameBuffer(Graphics g) {
48 Graphics2D g2d = (Graphics2D)g;
49 g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
50 RenderingHints.VALUE_RENDER_QUALITY);
51 g2d.drawImage(memImage, 0, 0, scaledWidth, scaledHeight, null);
52 }
53
54 //
55 // Try to disable focus traversal keys (JVMs 1.4 and higher).
56 //
57
58 private void disableFocusTraversalKeys() {
59 try {
60 Class[] argClasses = { Boolean.TYPE };
61 java.lang.reflect.Method method =
62 getClass().getMethod("setFocusTraversalKeysEnabled", argClasses);
63 Object[] argObjects = { new Boolean(false) };
64 method.invoke(this, argObjects);
65 } catch (Exception e) {}
66 }
67
68 }
69