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.

OptionsDialog.java 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2011-2012 Brian P. Hinz
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  17. * USA.
  18. */
  19. package com.tigervnc.vncviewer;
  20. import java.awt.*;
  21. import java.awt.event.*;
  22. import javax.swing.*;
  23. import javax.swing.border.*;
  24. import com.tigervnc.rfb.*;
  25. class OptionsDialog extends Dialog implements
  26. ActionListener,
  27. ItemListener
  28. {
  29. // Constants
  30. // Static variables
  31. static LogWriter vlog = new LogWriter("OptionsDialog");
  32. OptionsDialogCallback cb;
  33. JPanel FormatPanel, InputsPanel, MiscPanel, DefaultsPanel, SecPanel;
  34. JCheckBox autoSelect, customCompressLevel, noJpeg;
  35. JComboBox menuKey, compressLevel, qualityLevel, scalingFactor;
  36. ButtonGroup encodingGroup, colourGroup;
  37. JRadioButton zrle, hextile, tight, raw;
  38. JRadioButton fullColour, mediumColour, lowColour, veryLowColour;
  39. JCheckBox viewOnly, acceptClipboard, sendClipboard, acceptBell;
  40. JCheckBox fullScreen, shared, useLocalCursor;
  41. JCheckBox secVeNCrypt, encNone, encTLS, encX509;
  42. JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername;
  43. JButton okButton, cancelButton;
  44. JButton ca, crl;
  45. JButton defSaveButton;
  46. UserPrefs defaults;
  47. public OptionsDialog(OptionsDialogCallback cb_) {
  48. super(false);
  49. cb = cb_;
  50. setResizable(false);
  51. setTitle("VNC Viewer Options");
  52. defaults = new UserPrefs("vncviewer");
  53. getContentPane().setLayout(
  54. new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
  55. JTabbedPane tabPane = new JTabbedPane();
  56. ButtonGroup encodingGroup = new ButtonGroup();
  57. ButtonGroup colourGroup = new ButtonGroup();
  58. // Colour & Encoding tab
  59. FormatPanel=new JPanel(new GridBagLayout());
  60. autoSelect = new JCheckBox("Auto Select");
  61. autoSelect.addItemListener(this);
  62. JPanel encodingPanel = new JPanel(new GridBagLayout());
  63. encodingPanel.setBorder(BorderFactory.createTitledBorder("Preferred encoding"));
  64. zrle = addRadioCheckbox("ZRLE", encodingGroup, encodingPanel);
  65. hextile = addRadioCheckbox("Hextile", encodingGroup, encodingPanel);
  66. tight = addRadioCheckbox("Tight", encodingGroup, encodingPanel);
  67. raw = addRadioCheckbox("Raw", encodingGroup, encodingPanel);
  68. JPanel tightPanel = new JPanel(new GridBagLayout());
  69. customCompressLevel = new JCheckBox("Custom Compression Level");
  70. customCompressLevel.addItemListener(this);
  71. Object[] compressionLevels = { 1, 2, 3, 4, 5, 6 };
  72. compressLevel = new JComboBox(compressionLevels);
  73. JLabel compressionLabel = new JLabel("Level (1=fast, 6=best [4-6 are rarely useful])");
  74. noJpeg = new JCheckBox("Allow JPEG Compression");
  75. noJpeg.addItemListener(this);
  76. Object[] qualityLevels = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  77. qualityLevel = new JComboBox(qualityLevels);
  78. JLabel qualityLabel = new JLabel("Level (0=poor, 9=best)");
  79. // Hack to set the left inset on editable JComboBox
  80. if (UIManager.getLookAndFeel().getID() == "Windows") {
  81. compressLevel.setBorder(BorderFactory.createCompoundBorder(compressLevel.getBorder(),
  82. BorderFactory.createEmptyBorder(0,1,0,0)));
  83. } else if (UIManager.getLookAndFeel().getID() == "Metal") {
  84. ComboBoxEditor editor = compressLevel.getEditor();
  85. JTextField jtf = (JTextField)editor.getEditorComponent();
  86. jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0,2,0,0)));
  87. }
  88. Dimension size = compressLevel.getPreferredSize();
  89. compressLevel.setEditable(true);
  90. compressLevel.setPreferredSize(size);
  91. addGBComponent(customCompressLevel, tightPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,0,0,0));
  92. addGBComponent(compressLevel, tightPanel, 0, 1, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0));
  93. addGBComponent(compressionLabel, tightPanel, 1, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0));
  94. addGBComponent(noJpeg, tightPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,0,0,0));
  95. addGBComponent(qualityLevel, tightPanel, 0, 3, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0));
  96. addGBComponent(qualityLabel, tightPanel, 1, 3, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0));
  97. JPanel colourPanel = new JPanel(new GridBagLayout());
  98. colourPanel.setBorder(BorderFactory.createTitledBorder("Colour level"));
  99. fullColour = addRadioCheckbox("Full (all available colours)", colourGroup, colourPanel);
  100. mediumColour = addRadioCheckbox("Medium (256 colours)", colourGroup, colourPanel);
  101. lowColour = addRadioCheckbox("Low (64 colours)", colourGroup, colourPanel);
  102. veryLowColour = addRadioCheckbox("Very low(8 colours)", colourGroup, colourPanel);
  103. addGBComponent(autoSelect,FormatPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
  104. addGBComponent(encodingPanel,FormatPanel, 0, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,10,0,5));
  105. addGBComponent(colourPanel,FormatPanel, 1, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new Insets(0,0,0,5));
  106. addGBComponent(tightPanel,FormatPanel, 0, 2, 2, GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,5,0,5));
  107. // Inputs tab
  108. InputsPanel=new JPanel(new GridBagLayout());
  109. viewOnly = new JCheckBox("View Only (ignore mouse & keyboard)");
  110. viewOnly.addItemListener(this);
  111. acceptClipboard = new JCheckBox("Accept clipboard from server");
  112. acceptClipboard.addItemListener(this);
  113. sendClipboard = new JCheckBox("Send clipboard to server");
  114. sendClipboard.addItemListener(this);
  115. JLabel menuKeyLabel = new JLabel("Menu Key");
  116. String[] menuKeys =
  117. { "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" };
  118. menuKey = new JComboBox(menuKeys);
  119. menuKey.addItemListener(this);
  120. addGBComponent(viewOnly,InputsPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
  121. addGBComponent(acceptClipboard,InputsPanel, 0, 1, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
  122. addGBComponent(sendClipboard,InputsPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
  123. addGBComponent(menuKeyLabel,InputsPanel, 0, 3, 1, GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,5));
  124. addGBComponent(menuKey,InputsPanel, 1, 3, 1, GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
  125. // Misc tab
  126. MiscPanel=new JPanel(new GridBagLayout());
  127. fullScreen = new JCheckBox("Full-screen mode");
  128. fullScreen.addItemListener(this);
  129. shared = new JCheckBox("Shared connection (do not disconnect other viewers)");
  130. shared.addItemListener(this);
  131. useLocalCursor = new JCheckBox("Render cursor locally");
  132. useLocalCursor.addItemListener(this);
  133. acceptBell = new JCheckBox("Beep when requested by the server");
  134. acceptBell.addItemListener(this);
  135. JLabel scalingFactorLabel = new JLabel("Scaling Factor");
  136. Object[] scalingFactors = {
  137. "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%",
  138. "125%", "150%", "175%", "200%", "250%", "300%", "350%", "400%" };
  139. scalingFactor = new JComboBox(scalingFactors);
  140. // Hack to set the left inset on editable JComboBox
  141. if (UIManager.getLookAndFeel().getID() == "Windows") {
  142. scalingFactor.setBorder(BorderFactory.createCompoundBorder(compressLevel.getBorder(),
  143. BorderFactory.createEmptyBorder(0,1,0,0)));
  144. } else if (UIManager.getLookAndFeel().getID() == "Metal") {
  145. ComboBoxEditor sfe = scalingFactor.getEditor();
  146. JTextField sfeTextField = (JTextField)sfe.getEditorComponent();
  147. sfeTextField.setBorder(new CompoundBorder(sfeTextField.getBorder(),
  148. new EmptyBorder(0,2,0,0)));
  149. }
  150. scalingFactor.setEditable(true);
  151. scalingFactor.addItemListener(this);
  152. addGBComponent(fullScreen,MiscPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
  153. addGBComponent(shared,MiscPanel, 0, 1, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
  154. addGBComponent(useLocalCursor,MiscPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
  155. addGBComponent(acceptBell,MiscPanel, 0, 3, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
  156. addGBComponent(scalingFactorLabel,MiscPanel, 0, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,5));
  157. addGBComponent(scalingFactor,MiscPanel, 1, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
  158. // load/save tab
  159. DefaultsPanel=new JPanel(new GridBagLayout());
  160. JPanel configPanel = new JPanel(new GridBagLayout());
  161. configPanel.setBorder(BorderFactory.createTitledBorder("Configuration File"));
  162. JButton cfReloadButton = new JButton("Reload");
  163. cfReloadButton.addActionListener(this);
  164. addGBComponent(cfReloadButton,configPanel, 0, 0, 1, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  165. JButton cfSaveButton = new JButton("Save");
  166. cfSaveButton.addActionListener(this);
  167. addGBComponent(cfSaveButton,configPanel, 0, 1, 1, 1, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  168. JButton cfSaveAsButton = new JButton("Save As...");
  169. cfSaveAsButton.addActionListener(this);
  170. addGBComponent(cfSaveAsButton,configPanel, 0, 2, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  171. cfReloadButton.setEnabled(false);
  172. cfSaveButton.setEnabled(false);
  173. //cfSaveAsButton.setEnabled(!applet);
  174. JPanel defaultsPanel = new JPanel(new GridBagLayout());
  175. defaultsPanel.setBorder(BorderFactory.createTitledBorder("Defaults"));
  176. JButton defReloadButton = new JButton("Reload");
  177. defReloadButton.addActionListener(this);
  178. addGBComponent(defReloadButton,defaultsPanel, 0, 0, 1, 1, 0, 0, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  179. defSaveButton = new JButton("Save");
  180. defSaveButton.addActionListener(this);
  181. addGBComponent(defSaveButton,defaultsPanel, 0, 1, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
  182. addGBComponent(configPanel,DefaultsPanel, 0, 0, 1, GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.PAGE_START, new Insets(4,5,4,5));
  183. addGBComponent(defaultsPanel,DefaultsPanel, 1, 0, 1, GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.PAGE_START, new Insets(4,0,4,5));
  184. //defReloadButton.setEnabled(!applet);
  185. //defSaveButton.setEnabled(!applet);
  186. // security tab
  187. SecPanel=new JPanel(new GridBagLayout());
  188. JPanel encryptionPanel = new JPanel(new GridBagLayout());
  189. encryptionPanel.setBorder(BorderFactory.createTitledBorder("Session Encryption"));
  190. encNone = addCheckbox("None", null, encryptionPanel);
  191. encTLS = addCheckbox("Anonymous TLS", null, encryptionPanel);
  192. encX509 = addJCheckBox("TLS with X.509 certificates", null, encryptionPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.REMAINDER,new Insets(0,0,0,60),0,0));
  193. JPanel x509Panel = new JPanel(new GridBagLayout());
  194. x509Panel.setBorder(BorderFactory.createTitledBorder("X.509 certificates"));
  195. ca = new JButton("Load CA certificate");
  196. ca.addActionListener(this);
  197. crl = new JButton("Load CRL certificate");
  198. crl.addActionListener(this);
  199. addGBComponent(ca, x509Panel, 0, 0, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(2,2,2,2));
  200. addGBComponent(crl, x509Panel, 1, 0, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(2,2,2,2));
  201. JPanel authPanel = new JPanel(new GridBagLayout());
  202. authPanel.setBorder(BorderFactory.createTitledBorder("Authentication"));
  203. secNone = addCheckbox("None", null, authPanel);
  204. secVnc = addCheckbox("Standard VNC", null, authPanel);
  205. secPlain = addJCheckBox("Plaintext", null, authPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));
  206. secIdent = addJCheckBox("Ident", null, authPanel, new GridBagConstraints(0,3,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));
  207. sendLocalUsername = new JCheckBox("Send Local Username");
  208. sendLocalUsername.addItemListener(this);
  209. addGBComponent(sendLocalUsername, authPanel, 1, 2, 1, 2, 0, 0, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,20,0,0));
  210. secVeNCrypt = new JCheckBox("Extended encryption and authentication methods (VeNCrypt)");
  211. secVeNCrypt.addItemListener(this);
  212. addGBComponent(secVeNCrypt,SecPanel, 0, 0, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,30));
  213. addGBComponent(encryptionPanel,SecPanel, 0, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(0,10,2,5));
  214. addGBComponent(x509Panel,SecPanel, 0, 2, 1, 1, 2, 2, 1, 0, GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,10,2,5));
  215. addGBComponent(authPanel,SecPanel, 0, 3, 1, 1, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(2,10,2,5));
  216. tabPane.add(FormatPanel);
  217. tabPane.add(InputsPanel);
  218. tabPane.add(MiscPanel);
  219. tabPane.add(DefaultsPanel);
  220. tabPane.add(SecPanel);
  221. tabPane.addTab("Colour & Encoding", FormatPanel);
  222. tabPane.addTab("Inputs", InputsPanel);
  223. tabPane.addTab("Misc", MiscPanel);
  224. tabPane.addTab("Load / Save", DefaultsPanel);
  225. tabPane.addTab("Security", SecPanel);
  226. tabPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
  227. okButton = new JButton("OK");
  228. okButton.setPreferredSize(new Dimension(90,30));
  229. okButton.addActionListener(this);
  230. cancelButton = new JButton("Cancel");
  231. cancelButton.setPreferredSize(new Dimension(90,30));
  232. cancelButton.addActionListener(this);
  233. JPanel buttonPane = new JPanel();
  234. buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
  235. buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
  236. buttonPane.add(Box.createHorizontalGlue());
  237. buttonPane.add(okButton);
  238. buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
  239. buttonPane.add(cancelButton);
  240. buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
  241. this.getContentPane().add(tabPane);
  242. this.getContentPane().add(buttonPane);
  243. pack();
  244. }
  245. public void initDialog() {
  246. if (cb != null) cb.setOptions();
  247. zrle.setEnabled(!autoSelect.isSelected());
  248. hextile.setEnabled(!autoSelect.isSelected());
  249. tight.setEnabled(!autoSelect.isSelected());
  250. raw.setEnabled(!autoSelect.isSelected());
  251. fullColour.setEnabled(!autoSelect.isSelected());
  252. mediumColour.setEnabled(!autoSelect.isSelected());
  253. lowColour.setEnabled(!autoSelect.isSelected());
  254. veryLowColour.setEnabled(!autoSelect.isSelected());
  255. compressLevel.setEnabled(customCompressLevel.isSelected());
  256. qualityLevel.setEnabled(noJpeg.isSelected());
  257. sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&&
  258. (secPlain.isSelected()||secIdent.isSelected()));
  259. }
  260. JRadioButton addRadioCheckbox(String str, ButtonGroup group, JPanel panel) {
  261. JRadioButton c = new JRadioButton(str);
  262. GridBagConstraints gbc = new GridBagConstraints();
  263. gbc.anchor = GridBagConstraints.LINE_START;
  264. gbc.gridwidth = GridBagConstraints.REMAINDER;
  265. gbc.weightx = 1;
  266. gbc.weighty = 1;
  267. panel.add(c,gbc);
  268. group.add(c);
  269. c.addItemListener(this);
  270. return c;
  271. }
  272. JCheckBox addCheckbox(String str, ButtonGroup group, JPanel panel) {
  273. JCheckBox c = new JCheckBox(str);
  274. GridBagConstraints gbc = new GridBagConstraints();
  275. gbc.anchor = GridBagConstraints.LINE_START;
  276. gbc.gridwidth = GridBagConstraints.REMAINDER;
  277. gbc.weightx = 1;
  278. gbc.weighty = 1;
  279. panel.add(c,gbc);
  280. if (group != null)
  281. group.add(c);
  282. c.addItemListener(this);
  283. return c;
  284. }
  285. JCheckBox addJCheckBox(String str, ButtonGroup group, JPanel panel,
  286. GridBagConstraints gbc) {
  287. JCheckBox c = new JCheckBox(str);
  288. panel.add(c,gbc);
  289. if (group != null)
  290. group.add(c);
  291. c.addItemListener(this);
  292. return c;
  293. }
  294. public void actionPerformed(ActionEvent e) {
  295. Object s = e.getSource();
  296. if (s instanceof JButton && (JButton)s == okButton) {
  297. ok = true;
  298. if (cb != null) cb.getOptions();
  299. endDialog();
  300. } else if (s instanceof JButton && (JButton)s == cancelButton) {
  301. ok = false;
  302. endDialog();
  303. } else if (s instanceof JButton && (JButton)s == defSaveButton) {
  304. try {
  305. defaults.Save();
  306. } catch (java.lang.Exception x) { }
  307. } else if (s instanceof JButton && (JButton)s == ca) {
  308. JFileChooser fc = new JFileChooser();
  309. fc.setDialogTitle("Path to X509 CA certificate");
  310. int ret = fc.showOpenDialog(this);
  311. if (ret == JFileChooser.APPROVE_OPTION)
  312. CSecurityTLS.x509ca.setParam(fc.getSelectedFile().toString());
  313. } else if (s instanceof JButton && (JButton)s == crl) {
  314. JFileChooser fc = new JFileChooser();
  315. fc.setDialogTitle("Path to X509 CRL file");
  316. int ret = fc.showOpenDialog(this);
  317. if (ret == JFileChooser.APPROVE_OPTION)
  318. CSecurityTLS.x509crl.setParam(fc.getSelectedFile().toString());
  319. }
  320. }
  321. public void itemStateChanged(ItemEvent e) {
  322. Object s = e.getSource();
  323. if (s instanceof JCheckBox && (JCheckBox)s == autoSelect) {
  324. zrle.setEnabled(!autoSelect.isSelected());
  325. hextile.setEnabled(!autoSelect.isSelected());
  326. tight.setEnabled(!autoSelect.isSelected());
  327. raw.setEnabled(!autoSelect.isSelected());
  328. fullColour.setEnabled(!autoSelect.isSelected());
  329. mediumColour.setEnabled(!autoSelect.isSelected());
  330. lowColour.setEnabled(!autoSelect.isSelected());
  331. veryLowColour.setEnabled(!autoSelect.isSelected());
  332. defaults.setPref("autoSelect",(autoSelect.isSelected()) ? "on" : "off");
  333. }
  334. if (s instanceof JCheckBox && (JCheckBox)s == customCompressLevel) {
  335. compressLevel.setEnabled(customCompressLevel.isSelected());
  336. defaults.setPref("customCompressLevel",(customCompressLevel.isSelected()) ? "on" : "off");
  337. }
  338. if (s instanceof JCheckBox && (JCheckBox)s == noJpeg) {
  339. qualityLevel.setEnabled(noJpeg.isSelected());
  340. defaults.setPref("noJpeg",(noJpeg.isSelected()) ? "on" : "off");
  341. }
  342. if (s instanceof JCheckBox && (JCheckBox)s == sendLocalUsername) {
  343. defaults.setPref("sendLocalUsername",(sendLocalUsername.isSelected()) ? "on" : "off");
  344. }
  345. if (s instanceof JCheckBox && (JCheckBox)s == secVeNCrypt) {
  346. encNone.setEnabled(secVeNCrypt.isSelected());
  347. encTLS.setEnabled(secVeNCrypt.isSelected());
  348. encX509.setEnabled(secVeNCrypt.isSelected());
  349. ca.setEnabled(secVeNCrypt.isSelected());
  350. crl.setEnabled(secVeNCrypt.isSelected());
  351. secIdent.setEnabled(secVeNCrypt.isSelected());
  352. secNone.setEnabled(secVeNCrypt.isSelected());
  353. secVnc.setEnabled(secVeNCrypt.isSelected());
  354. secPlain.setEnabled(secVeNCrypt.isSelected());
  355. sendLocalUsername.setEnabled(secVeNCrypt.isSelected());
  356. }
  357. if (s instanceof JCheckBox && (JCheckBox)s == secIdent ||
  358. s instanceof JCheckBox && (JCheckBox)s == secPlain) {
  359. sendLocalUsername.setEnabled(secIdent.isSelected()||secPlain.isSelected());
  360. }
  361. }
  362. }