17 package com.generalrobotix.ui.util;
20 import java.awt.event.*;
21 import javax.swing.filechooser.*;
25 @SuppressWarnings(
"serial")
32 UIManager.put(
"FileChooser.cancelButtonText",
MessageBundle.
get(
"FileChooser.cancelButtonText"));
33 UIManager.put(
"FileChooser.cancelButtonToolTipText",
MessageBundle.
get(
"FileChooser.cancelButtonToolTipText"));
34 UIManager.put(
"FileChooser.acceptAllFileFilterText",
MessageBundle.
get(
"FileChooser.acceptAllFileFilterText"));
35 UIManager.put(
"FileChooser.filesOfTypeLabelText",
MessageBundle.
get(
"FileChooser.filesOfTypeLabelText"));
36 UIManager.put(
"FileChooser.fileNameLabelText",
MessageBundle.
get(
"FileChooser.fileNameLabelText"));
37 UIManager.put(
"FileChooser.lookInLabelText",
MessageBundle.
get(
"FileChooser.lookInLabelText"));
38 UIManager.put(
"FileChooser.upFolderToolTipText",
MessageBundle.
get(
"FileChooser.upFolderToolTipText"));
39 UIManager.put(
"FileChooser.homeFolderToolTipText",
MessageBundle.
get(
"FileChooser.homeFolderToolTipText"));
40 UIManager.put(
"FileChooser.newFolderToolTipText",
MessageBundle.
get(
"FileChooser.newFolderToolTipText"));
41 UIManager.put(
"FileChooser.listViewButtonToolTipText",
MessageBundle.
get(
"FileChooser.listViewButtonToolTipText"));
42 UIManager.put(
"FileChooser.detailsViewButtonToolTipText",
MessageBundle.
get(
"FileChooser.detailsViewButtonToolTipText"));
47 text_ =
new JTextField();
49 JButton button =
new JButton(
MessageBundle.
get(
"dialog.fileinput.filechoose"));
50 button.addActionListener(
51 new ActionListener() {
52 public void actionPerformed(ActionEvent evt) {
53 JFileChooser chooser =
new JFileChooser(basedir_);
54 for (
int i = 0;
i < fileFilter_.length;
i ++) {
55 chooser.addChoosableFileFilter(createFilter(fileFilter_[
i]));
59 chooser.setApproveButtonMnemonic(
'o');
60 chooser.setApproveButtonToolTipText(
MessageBundle.
get(
"dialog.fileopen.title"));
62 if (result == JFileChooser.APPROVE_OPTION) {
63 text_.setText( chkExtension(chooser.getSelectedFile().getPath()) );
69 setLayout(
new BoxLayout(
this, BoxLayout.X_AXIS));
71 add(Box.createHorizontalStrut(12));
76 return chkExtension(text_.getText().trim());
84 return new FileFilter() {
85 public boolean accept(java.io.File fileobj ) {
86 if (fileobj.isDirectory()) {
90 String extension =
"";
92 if (fileobj.getPath().lastIndexOf(
'.') > 0) {
94 fileobj.getPath().substring(
95 fileobj.getPath().lastIndexOf(
'.') + 1
99 return extension.equals(filter);
110 public String getDescription() {
111 return filter +
" files (*." + filter +
")";
117 if (fileFilter_.length == 1) {
118 if (!localPath.matches(
".+\\." + fileFilter_[0] +
"$")) {
120 localPath += fileFilter_[0];
static final String get(String key)