javax.swing.JFileChooser.setAccessory()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中javax.swing.JFileChooser.setAccessory()方法的一些代码示例,展示了JFileChooser.setAccessory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.setAccessory()方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:setAccessory

JFileChooser.setAccessory介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JTextField field = new JTextField("Hello, World");
JPanel accessory = new JPanel();
accessory.setLayout(new FlowLayout());
accessory.add(field);

JFileChooser chooser = new JFileChooser();
chooser.setAccessory(accessory);
int ret = chooser.showOpenDialog(frame);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
  public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("fileFilterChanged")) {
      OutputFormat outputFormat = fileFilterOutputFormatMap.get(evt.getNewValue());
      saveChooser.setAccessory((outputFormat == null) ? null : outputFormat.getOutputFormatAccessory());
    }
  }
});

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
  public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("fileFilterChanged")) {
      InputFormat inputFormat = fileFilterInputFormatMap.get(evt.getNewValue());
      openChooser.setAccessory((inputFormat == null) ? null : inputFormat.getInputFormatAccessory());
    }
  }
});

代码示例来源:origin: com.harium.etyl/etyl

@Override
public void openDialog() {
  if(opened) {
    return;
  }
  
  chooser = new JFileChooser(path);
  
  PreviewPane previewPane = new PreviewPane();
  chooser.setAccessory(previewPane);
  chooser.addPropertyChangeListener(previewPane);
  chooser.setVisible(true);
  opened = true;
  
  new Thread(this).start();
}

代码示例来源:origin: openpreserve/jhove

chooser.setAccessory (accessory);

代码示例来源:origin: stackoverflow.com

JFileChooser chooser = new JFileChooser();
JComponent panel = new JPanel();
panel.add(new JButton("my dummy Accessory"));
panel.setBackground(Color.RED);
chooser.setAccessory(panel);

JComponent center = null;
BorderLayout layout = (BorderLayout) chooser.getLayout();
for (Component child : chooser.getComponents()) {
  if (BorderLayout.CENTER == layout.getConstraints(child)) {
    center = (JComponent) child;
  }
}
if (center != null)
  center.add(panel, BorderLayout.SOUTH);

代码示例来源:origin: com.harium/etyl

@Override
public void openDialog() {
  if(opened) {
    return;
  }
  
  chooser = new JFileChooser(path);
  
  PreviewPane previewPane = new PreviewPane();
  chooser.setAccessory(previewPane);
  chooser.addPropertyChangeListener(previewPane);
  chooser.setVisible(true);
  opened = true;
  
  new Thread(this).start();
}

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-base-swing

public void customResultAvailable(Void result)
  {
    final JFileChooser	filechooser = new JFileChooser(view.getCurrentDirectory(), view);
    view.setFileChooser(filechooser);
    JPanel pan = new JPanel(new GridBagLayout());
    JButton refresh = new JButton("Refresh");
    pan.add(refresh, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHEAST,
      GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0));
    filechooser.setAccessory(pan);
    refresh.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        view.clearCache();
        filechooser.rescanCurrentDirectory();
      }
    });
    fut.setResult(filechooser);
  }
});

代码示例来源:origin: stackoverflow.com

JFileChooser fileChooser = new JFileChooser();
Chooser c = new Chooser(fileChooser);
fileChooser.setAccessory(c);
fileChooser.showOpenDialog(null);

代码示例来源:origin: robward-scisys/sldeditor

public void actionPerformed(ActionEvent e) {
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new java.io.File("."));
    chooser.setDialogTitle(
        Localisation.getString(
            SaveSLDTool.class, "SaveSLDTool.destinationFolder"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    //
    // Disable the "All files" option.
    //
    chooser.setAcceptAllFileFilterUsed(false);
    // Save external images option
    JPanel accessory = new JPanel();
    JCheckBox isOpenBox =
        new JCheckBox(
            Localisation.getString(
                SaveSLDTool.class,
                "SaveSLDTool.saveExternalImages"));
    accessory.setLayout(new BorderLayout());
    accessory.add(isOpenBox, BorderLayout.CENTER);
    chooser.setAccessory(accessory);
    if (chooser.showSaveDialog(saveAllSLD) == JFileChooser.APPROVE_OPTION) {
      worker.saveAllSLDToFolder(
          sldDataList, chooser.getSelectedFile(), isOpenBox.isSelected());
    }
  }
});

代码示例来源:origin: com.mgmtp.gcviewer/gcviewer

public OpenFile(final GCViewerGui gcViewer) {
  this.gcViewer = gcViewer;
  putValue(NAME, GCViewerGui.localStrings.getString("main_frame_menuitem_open_file"));
  putValue(SHORT_DESCRIPTION, GCViewerGui.localStrings.getString("main_frame_menuitem_hint_open_file"));
  putValue(MNEMONIC_KEY, new Integer(GCViewerGui.localStrings.getString("main_frame_menuitem_mnemonic_open_file").charAt(0)));
  putValue(ACTION_COMMAND_KEY, "open");
  putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ));
  putValue(SMALL_ICON, new ImageIcon(Toolkit.getDefaultToolkit().getImage(gcViewer.getClass().getResource("images/open.png"))));
  openDialog = new JFileChooser();
  openDialog.setDialogTitle(GCViewerGui.localStrings.getString("fileopen_dialog_title"));
  openDialog.setMultiSelectionEnabled(true);
  openDialog.addChoosableFileFilter(ExtensionFileFilter.GcExtensionFilter);
  openDialog.addChoosableFileFilter(ExtensionFileFilter.TxtExtensionFilter);
  openDialog.addChoosableFileFilter(ExtensionFileFilter.LogExtensionFilter);
  addURLCheckBox = new JCheckBox(GCViewerGui.localStrings.getString("fileopen_dialog_add_checkbox"), false);
  addURLCheckBox.setVerticalTextPosition(SwingConstants.TOP);
  addURLCheckBox.setToolTipText(GCViewerGui.localStrings.getString("fileopen_dialog_hint_add_checkbox"));
  final JPanel panel = new JPanel(new GridBagLayout());
  final GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.anchor = GridBagConstraints.NORTH;
  gridBagConstraints.weighty = 2;
  panel.add(addURLCheckBox, gridBagConstraints);
  openDialog.setAccessory(panel);
}

代码示例来源:origin: de.sciss/prefuse-core

private void init() {
  scaler  = new ScaleSelector();
  chooser = new JFileChooser();
  chooser.setDialogType(JFileChooser.SAVE_DIALOG);
  chooser.setDialogTitle("Export Prefuse Display...");
  chooser.setAcceptAllFileFilterUsed(false);
  
  HashSet seen = new HashSet();
  String[] fmts = ImageIO.getWriterFormatNames();
  for ( int i=0; i<fmts.length; i++ ) {
    String s = fmts[i].toLowerCase();
    if ( s.length() == 3 && !seen.contains(s) ) {
      seen.add(s);
      chooser.setFileFilter(new SimpleFileFilter(s, 
          s.toUpperCase()+" Image (*."+s+")"));
    }
  }
  seen.clear(); seen = null;
  chooser.setAccessory(scaler);
}

代码示例来源:origin: stackoverflow.com

import java.io.File;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;

public class JavaApplication4 {

  public static void main(String[] args) {

    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        JFileChooser fc = new JFileChooser();
        FileListAccessory accessory = new FileListAccessory(fc);
        fc.setAccessory(accessory);

        int open = fc.showOpenDialog(fc);
        if (open == JFileChooser.APPROVE_OPTION) {
          DefaultListModel model = accessory.getModel();
          for (int i = 0; i < model.getSize(); i++) {
            System.out.println(((File)model.getElementAt(i)).getName());
          }

        }
      }
    });
  }
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

/**
 * Shows a file save dialog with the given filter file extensions.
 * 
 * @param extensions
 *            used to filter filenames
 * @return File
 */
public static File showSaveDialog(String[] extensions) {
  File dir = (Config.lastSavedFile == null) ? new File(System.getProperty("user.dir")) : new File(Config.lastSavedFile);
  JFileChooser fc = new JFileChooser(dir);
  fc.addChoosableFileFilter(new CustomFileFilter(extensions));
  OVTK2Desktop desktop = OVTK2Desktop.getInstance();
  ChooserAccessory accessory = new ChooserAccessory();
  fc.setAccessory(accessory);
  // in response to a button click:
  int returnVal = fc.showSaveDialog(desktop.getMainFrame());
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    accessory.perform(desktop);
    File file = fc.getSelectedFile();
    Config.lastSavedFile = file.getAbsolutePath();
    System.out.println("Saving: " + file.getName() + ".");
    return file;
  }
  System.out.println("Save command cancelled by user.");
  return null;
}

代码示例来源:origin: lbalazscs/Pixelitor

private static void initOpenChooser() {
  assert EventQueue.isDispatchThread() : "not EDT thread";
  if (openChooser == null) {
    //noinspection NonThreadSafeLazyInitialization
    openChooser = new JFileChooser(Dirs.getLastOpen());
    openChooser.setName("open");
    setDefaultOpenExtensions();
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    ProgressPanel progressPanel = new ProgressPanel();
    ImagePreviewPanel preview = new ImagePreviewPanel(progressPanel);
    p.add(preview, BorderLayout.CENTER);
    p.add(progressPanel, BorderLayout.SOUTH);
    openChooser.setAccessory(p);
    openChooser.addPropertyChangeListener(preview);
  }
}

代码示例来源:origin: dsukhoroslov/bagri

private void onAddDocuments() {
  JFileChooser chooser = new JFileChooser();
  chooser.setDialogTitle("Select Directory");
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  if (currentPath != null) {
    chooser.setCurrentDirectory(new File(currentPath));
  }
  CollectionPanel cp = null;
  if (collections != null) {
    cp = new CollectionPanel(getCollectionNames());
    chooser.setAccessory(cp);
  }
  int returnVal = chooser.showOpenDialog(this.getParent());
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    currentPath = chooser.getCurrentDirectory().getAbsolutePath();
    java.util.Collection<String> clns = null;
    if (cp != null) {
      clns = cp.getSelectedCollections();
    }
    try {
      if (docMgr.storeDocuments(chooser.getSelectedFile().getAbsolutePath(), clns)) {
        refreshDocuments(clns);
      }
    } catch (Exception ex) {
      ErrorUtil.showError(this.getParent(), ex);
    }
  }
}

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

public static JFileChooser createOpenFileChooser(
  final IPreferences preferences,
  final IOpenFileChooserConfiguration configuration) {
 final JFileChooser fileChooser = createFileChooser(preferences, configuration);
 final IAccessoryFactory accessoryFactory = configuration.getFileViewFactory();
 fileChooser.setAccessory(accessoryFactory.create(fileChooser));
 fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
 return fileChooser;
}

代码示例来源:origin: dsukhoroslov/bagri

private void onAddDocument() {
  JFileChooser chooser = new JFileChooser();
  chooser.setDialogTitle("Select File");
  String docType = schema.getDataFormat();
  FileNameExtensionFilter filter = new FileNameExtensionFilter(docType + " Documents", docType.toLowerCase());
  chooser.setFileFilter(filter);
  if (currentPath != null) {
    chooser.setCurrentDirectory(new File(currentPath));
  }
  CollectionPanel cp = null;
  if (collections != null) {
    cp = new CollectionPanel(getCollectionNames());
    chooser.setAccessory(cp);
  }
  int returnVal = chooser.showOpenDialog(this.getParent());
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    currentPath = chooser.getCurrentDirectory().getAbsolutePath();
    java.util.Collection<String> clns = null;
    if (cp != null) {
      clns = cp.getSelectedCollections();
    }
    try {
      Document doc = docMgr.storeDocument(chooser.getSelectedFile().getAbsolutePath(), clns);
      insertDocument(doc, clns);
    } catch (ServiceException ex) {
      ErrorUtil.showError(this.getParent(), ex);
    }
  }
}

代码示例来源:origin: realXuJiang/bigtable-sql

chooser.setAccessory(new ChooserPreviewer());

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

pathPanel = new PathPanel();
fileChooser.setAccessory(pathPanel);
int ret = fileChooser.showOpenDialog(this);
if (ret == JFileChooser.CANCEL_OPTION) {

相关文章

JFileChooser类方法