Package org.openbp.swing.components.popupfield

Examples of org.openbp.swing.components.popupfield.JPopupField$PopupFieldFocusListener


    JLabel outputDirLabel = new JLabel(resourceCollection.getRequiredString("wizard.result.outputdirlabel"));
    outputDirLabel.setBorder(new EmptyBorder(0, 0, 0, 5));
    panel.add(outputDirLabel, BorderLayout.WEST);

    // Text field
    final JPopupField outputDirField = new JPopupField()
    {
      public boolean isPopupVisible()
      {
        return false;
      }

      public void setPopupVisible(boolean popupVisible)
      {
        if (popupVisible)
        {
          // Prepare file chooser
          JFileChooser fileChooser = new JFileChooser();
          fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

          // Set the dir of the file chooser to the current path value
          File f = new File(getText());
          if (f.exists())
          {
            fileChooser.setCurrentDirectory(f);
          }

          // Show the file chooser
          int retVal = fileChooser.showOpenDialog(null);

          // If a file has been choosen, set the new value.
          if (retVal == JFileChooser.APPROVE_OPTION)
          {
            setText(fileChooser.getSelectedFile().getPath());
          }
        }
      }
    };

    outputDirField.getTextField().getDocument().addDocumentListener(new DocumentListener()
    {
      /**
       * @see javax.swing.event.DocumentListener#changedUpdate(DocumentEvent)
       */
      public void changedUpdate(DocumentEvent e)
      {
        getContext().setOutputRootDir(outputDirField.getText());
      }

      /**
       * @see javax.swing.event.DocumentListener#insertUpdate(DocumentEvent)
       */
      public void insertUpdate(DocumentEvent e)
      {
        getContext().setOutputRootDir(outputDirField.getText());
      }

      /**
       * @see javax.swing.event.DocumentListener#removeUpdate(DocumentEvent)
       */
      public void removeUpdate(DocumentEvent e)
      {
        getContext().setOutputRootDir(outputDirField.getText());
      }
    });

    panel.add(outputDirField, BorderLayout.CENTER);

    outputDirField.setText(getContext().getOutputRootDir());

    return panel;
  }
View Full Code Here


    this.filter = filter;
    this.dirSelection = dirSelection;

    // Prepare text field
    path = new JPopupField()
    {
      public boolean isPopupVisible()
      {
        return false;
      }
View Full Code Here

TOP

Related Classes of org.openbp.swing.components.popupfield.JPopupField$PopupFieldFocusListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.