aboutsummaryrefslogtreecommitdiffstats
path: root/java/com/tigervnc/vncviewer/Dialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/tigervnc/vncviewer/Dialog.java')
-rw-r--r--java/com/tigervnc/vncviewer/Dialog.java44
1 files changed, 33 insertions, 11 deletions
diff --git a/java/com/tigervnc/vncviewer/Dialog.java b/java/com/tigervnc/vncviewer/Dialog.java
index 8bf19799..a2fb04fe 100644
--- a/java/com/tigervnc/vncviewer/Dialog.java
+++ b/java/com/tigervnc/vncviewer/Dialog.java
@@ -31,8 +31,10 @@ package com.tigervnc.vncviewer;
import java.awt.*;
import java.awt.Dialog.*;
import java.awt.event.*;
+import java.io.File;
import javax.swing.*;
import javax.swing.border.*;
+import javax.swing.filechooser.*;
import javax.swing.text.*;
class Dialog extends JDialog implements ActionListener,
@@ -52,7 +54,7 @@ class Dialog extends JDialog implements ActionListener,
}
}
- public boolean showDialog(Component c) {
+ public void showDialog(Component c) {
initDialog();
if (c != null) {
setLocationRelativeTo(c);
@@ -63,26 +65,19 @@ class Dialog extends JDialog implements ActionListener,
int y = (dpySize.height - mySize.height) / 2;
setLocation(x, y);
}
- fullScreenWindow = Viewport.getFullScreenWindow();
- if (fullScreenWindow != null)
- Viewport.setFullScreenWindow(null);
if (getModalityType() == ModalityType.APPLICATION_MODAL)
setAlwaysOnTop(true);
setVisible(true);
- return ret;
}
- public boolean showDialog() {
- return showDialog(null);
+ public void showDialog() {
+ showDialog(null);
}
public void endDialog() {
setVisible(false);
setAlwaysOnTop(false);
- fullScreenWindow = Viewport.getFullScreenWindow();
- if (fullScreenWindow != null)
- Viewport.setFullScreenWindow(fullScreenWindow);
}
// initDialog() can be overridden in a derived class. Typically it is used
@@ -137,6 +132,33 @@ class Dialog extends JDialog implements ActionListener,
return width + gap;
}
+ public static File showChooser(String title, File defFile,
+ Container c, FileNameExtensionFilter f) {
+ JFileChooser fc = new JFileChooser(defFile);
+ fc.setDialogTitle(title);
+ fc.setApproveButtonText("OK \u21B5");
+ fc.setFileHidingEnabled(false);
+ if (f != null)
+ fc.setFileFilter(f);
+ if (fc.showOpenDialog(c) == JFileChooser.APPROVE_OPTION)
+ return fc.getSelectedFile();
+ else
+ return null;
+ }
+
+ public static File showChooser(String title, File defFile, Container c) {
+ return showChooser(title, defFile, c, null);
+ }
+
+ protected File showChooser(String title, File defFile,
+ FileNameExtensionFilter f) {
+ return showChooser(title, defFile, this, f);
+ }
+
+ protected File showChooser(String title, File defFile) {
+ return showChooser(title, defFile, this);
+ }
+
protected class GroupedJRadioButton extends JRadioButton {
public GroupedJRadioButton(String l, ButtonGroup g, JComponent c) {
super(l);
@@ -181,9 +203,9 @@ class Dialog extends JDialog implements ActionListener,
JTextField jtf = (JTextField)editor.getEditorComponent();
jtf.setDocument(doc);
}
+
}
private Window fullScreenWindow;
- protected boolean ret = true;
}