Example #1
0
  /** Implementing the action of pressing the ok button. */
  public void okButton_actionPerformed() {

    String file = null;
    file = fileChooser.getFileName();
    fileChooser.setCurrentFileName(file);
    setVisible(false);
    if (!(file == null)) {
      notifyListeners(file);
    }
  }
Example #2
0
 /** Called when the user pressed the enter button. */
 @Override
 public void enterPressed() {
   String file = null;
   file = fileChooser.getFileName();
   fileChooser.setCurrentFileName(file);
   if (!(file == null)) {
     notifyListeners(file);
   }
   setVisible(false);
 }
Example #3
0
 // Initialization.
 private void jbInit() {
   fileChooser.addListener(this);
   fileChooser.setWindowLocation(647, 3);
   this.getContentPane().setLayout(null);
   setTitle("Files selection");
   fileChooser.setBounds(new Rectangle(5, 2, 482, 48));
   okButton.setToolTipText("OK");
   okButton.setIcon(okIcon);
   okButton.setBounds(new Rectangle(124, 64, 63, 44));
   okButton.addActionListener(e -> okButton_actionPerformed());
   cancelButton.setBounds(new Rectangle(282, 63, 63, 44));
   cancelButton.addActionListener(e -> cancelButton_actionPerformed());
   cancelButton.setToolTipText("CANCEL");
   cancelButton.setIcon(cancelIcon);
   this.getContentPane().add(fileChooser, null);
   this.getContentPane().add(cancelButton, null);
   this.getContentPane().add(okButton, null);
   setSize(496, 150);
   setLocation(145, 250);
 }
Example #4
0
  /** Constructs a new FilesChooserWindow. */
  public FileChooserWindow(FileFilter filter) {
    listeners = new Vector<FilesTypeListener>();
    fileChooser = new ViewableFileChooserComponent();
    fileChooser.setFilter(filter);

    try {
      okIcon = new ImageIcon(Paths.get(ClassLoader.getSystemResource("ok.gif").toURI()).toString());
      cancelIcon =
          new ImageIcon(Paths.get(ClassLoader.getSystemResource("cancel.gif").toURI()).toString());
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    jbInit();
  }
Example #5
0
 /** Returns the textfield. */
 public JTextField getTextField() {
   return fileChooser.getTextField();
 }
Example #6
0
 /** Implementing the action of pressing the cancel button. */
 public void cancelButton_actionPerformed() {
   fileChooser.showCurrentFileName();
   setVisible(false);
 }
Example #7
0
 /** Shows the file chooser window. */
 public void showWindow() {
   setVisible(true);
   fileChooser.getTextField().requestFocus();
 }
Example #8
0
 /** Sets the name of the file chooser. */
 @Override
 public void setName(String name) {
   fileChooser.setName(name);
 }
Example #9
0
 /** Sets the file name (which is written inside the text field). */
 public void setFileName(String name) {
   fileChooser.setCurrentFileName(name);
   fileChooser.showCurrentFileName();
 }