You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VncCanvas2.java 1.9KB

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