本文整理了Java中javax.swing.JFileChooser.addActionListener()
方法的一些代码示例,展示了JFileChooser.addActionListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.addActionListener()
方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:addActionListener
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private static JFileChooser createFileChooser() {
final JFileChooser chooser = new JFileChooser();
// sets up default file view
try {
chooserFile = new File((new File(".").getCanonicalPath()));
} catch (Exception e) {
// go with current directory.
}
chooser.setCurrentDirectory(chooserFile);
chooser.addActionListener(e -> {
if(e.getActionCommand().equals("ApproveSelection")) {
chooserFile = chooser.getSelectedFile();
}
});
chooser.setMultiSelectionEnabled(true);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
return chooser;
}
代码示例来源:origin: org.netbeans.api/org-openide-util
chooser.addActionListener(l);
代码示例来源:origin: org.netbeans.api/org-openide-util-ui
chooser.addActionListener(l);
代码示例来源:origin: xyz.cofe/gui.swing
public static Closeable onActionPerformed( final JFileChooser button, final Reciver<ActionEvent> consumer ){
if( button==null )throw new IllegalArgumentException( "button==null" );
if( consumer==null )throw new IllegalArgumentException( "consumer==null" );
final ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
consumer.recive(e);
}
};
button.addActionListener(al);
Closeable cl = new Closeable() {
@Override
public void close() throws IOException {
button.removeActionListener(al);
}};
return cl;
}
代码示例来源:origin: stackoverflow.com
JFileChooser instance = new JFileChooser()
{
protected JDialog createDialog(Component parent) throws HeadlessException
{
JDialog dialog = super.createDialog(parent);
dialog.setModalityType(ModalityType.DOCUMENT_MODAL);
return dialog;
}
};
instance.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (JFileChooser.APPROVE_SELECTION.equals(e.getActionCommand()))
{
File file = ((JFileChooser)e.getSource()).getSelectedFile();
//loadFromFile(file); // My custom function for loading from a File
}
}
});
instance.showOpenDialog(this);
代码示例来源:origin: stackoverflow.com
public void createPanel3() {
panel3 = new JPanel();
panel3.setLayout(new BorderLayout());
panel3.setPreferredSize(new Dimension(400, 100));
panel3.setMinimumSize(new Dimension(100, 50));
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser
.setDialogTitle("Browse naar de locatie waar je de gesorteerde bestanden wil zetten en klik op \"OPEN\"");
panel3.add(fileChooser, BorderLayout.NORTH);
fileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
System.out.println("File selected: " + fileChooser.getSelectedFile());
}
}
});
}
代码示例来源:origin: edu.stanford.nlp/stanford-corenlp
private static JFileChooser createFileChooser() {
final JFileChooser chooser = new JFileChooser();
// sets up default file view
try {
chooserFile = new File((new File(".").getCanonicalPath()));
} catch (Exception e) {
// go with current directory.
}
chooser.setCurrentDirectory(chooserFile);
chooser.addActionListener(e -> {
if(e.getActionCommand().equals("ApproveSelection")) {
chooserFile = chooser.getSelectedFile();
}
});
chooser.setMultiSelectionEnabled(true);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
return chooser;
}
代码示例来源:origin: pavelfatin/typometer
private static JFileChooser createFileChooser(int type, String title) {
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(type);
chooser.setDialogTitle(title);
chooser.addChoosableFileFilter(CSV_FILE_FILTER);
chooser.setFileFilter(CSV_FILE_FILTER);
chooser.addActionListener(action -> {
if (JFileChooser.APPROVE_SELECTION.equals(action.getActionCommand())) {
myCurrentDirectory = Optional.of(chooser.getCurrentDirectory());
}
});
myCurrentDirectory.ifPresent(chooser::setCurrentDirectory);
return chooser;
}
代码示例来源:origin: pavelfatin/typometer
private static JFileChooser createFileChooser(int type, String title) {
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(type);
chooser.setDialogTitle(title);
chooser.addChoosableFileFilter(PNG_FILE_FILTER);
chooser.setFileFilter(PNG_FILE_FILTER);
chooser.addActionListener(action -> {
if (JFileChooser.APPROVE_SELECTION.equals(action.getActionCommand())) {
myCurrentDirectory = Optional.of(chooser.getCurrentDirectory());
}
});
myCurrentDirectory.ifPresent(chooser::setCurrentDirectory);
return chooser;
}
代码示例来源:origin: freeplane/freeplane
fileChooser.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent pE) {
firePropertyChangeEvent();
代码示例来源:origin: org.swinglabs/swingx-beaninfo
/** Creates a new instance of Painter2PropertyEditor */
public Painter2PropertyEditor() {
picker = new JFileChooser();
picker.setApproveButtonText("Load Painter");
picker.setMultiSelectionEnabled(false);
picker.setSelectedFile(new File("/Users/joshy/projects/current/AB5k/src/java/ab5k/desklet/"));
picker.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
try {
File file = picker.getSelectedFile();
painter = new URLPainter(file);
//painter = PainterUtil.loadPainter(file);
firePropertyChange();
log("loaded the painter: " + painter);
} catch (Throwable ex) {
//System.out.println("error loading the painter: " + ex.getMessage());
//ex.printStackTrace();
StringWriter wrt = new StringWriter();
ex.printStackTrace(new PrintWriter(wrt));
JOptionPane.showMessageDialog(picker,ex.getMessage() + " " + wrt.toString());// + painter.getClass().getName());
}
}
});
}
代码示例来源:origin: chungkwong/MathOCR
public MathInspector(){
setLeftComponent(fileChooser);
Box box=Box.createVerticalBox();
box.add(preview);
box.add(output);
setRightComponent(new JScrollPane(box));
fileChooser.addActionListener((e)->inspect(fileChooser.getSelectedFile()));
}
private void inspect(File file){
代码示例来源:origin: com.github.yannrichet/JMathPlot
fileChooser.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
saveFile();
代码示例来源:origin: chungkwong/MathOCR
public SceneTextDetector(){
super();
JPanel chooser=new JPanel(new BorderLayout());
detectors.setSelectedIndex(0);
chooser.add(detectors,BorderLayout.NORTH);
chooser.add(fileChooser,BorderLayout.CENTER);
chooser.add(invert,BorderLayout.SOUTH);
detectors.addActionListener((e)->refresh());
invert.addActionListener((e)->refresh());
fileChooser.addActionListener((e)->refresh());
setLeftComponent(chooser);
icon.setVerticalAlignment(SwingConstants.TOP);
icon.setHorizontalAlignment(SwingConstants.LEFT);
icon.addMouseMotionListener(this);
setRightComponent(new JScrollPane(icon));
}
private void refresh(){
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
m_FileChooser.setApproveButtonMnemonic('S');
m_FileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
m_FileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String cmdString = e.getActionCommand();
代码示例来源:origin: chungkwong/MathOCR
public SourceInspector(JPanel parent){
super(parent);
JFileChooser fileChooser=new JFileChooser();
fileChooser.setCurrentDirectory(directory);
fileChooser.setMultiSelectionEnabled(true);
fileChooser.addActionListener((e)->{
File[] selected=fileChooser.getSelectedFiles();
directory=fileChooser.getCurrentDirectory();
files=new LinkedList<>();
Arrays.stream(selected).forEach((file)->files.add(file));
processFile();
});
add(fileChooser,BorderLayout.CENTER);
JPanel sample=new JPanel(new BorderLayout());
FontChooser fontChooser=new FontChooser();
sample.add(fontChooser,BorderLayout.WEST);
JTextField text=new JTextField();
sample.add(text,BorderLayout.SOUTH);
add(sample,BorderLayout.SOUTH);
text.addActionListener((e)->{
call(new ComponentInspector(),drawImage(text.getText(),fontChooser.getFont()));
});
}
private void processFile(){
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/** Constructor */
public SaverCustomizer() {
setLayout(new BorderLayout());
m_fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
m_fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
m_fileChooser.setApproveButtonText("Select directory");
m_fileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
try {
File selectedFile = m_fileChooser.getSelectedFile();
m_directoryText.setText(selectedFile.toString());
/* (m_dsSaver.getSaver()).setFilePrefix(m_prefixText.getText());
(m_dsSaver.getSaver()).setDir(m_fileChooser.getSelectedFile().getPath());
m_dsSaver.
setRelationNameForFilename(m_relationNameForFilename.isSelected()); */
} catch (Exception ex) {
ex.printStackTrace();
}
}
// closing
if (m_fileChooserFrame != null) {
m_fileChooserFrame.dispose();
}
}
});
}
代码示例来源:origin: Waikato/weka-trunk
/** Constructor */
public SaverCustomizer() {
setLayout(new BorderLayout());
m_fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
m_fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
m_fileChooser.setApproveButtonText("Select directory");
m_fileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
try {
File selectedFile = m_fileChooser.getSelectedFile();
m_directoryText.setText(selectedFile.toString());
/* (m_dsSaver.getSaver()).setFilePrefix(m_prefixText.getText());
(m_dsSaver.getSaver()).setDir(m_fileChooser.getSelectedFile().getPath());
m_dsSaver.
setRelationNameForFilename(m_relationNameForFilename.isSelected()); */
} catch (Exception ex) {
ex.printStackTrace();
}
}
// closing
if (m_fileChooserFrame != null) {
m_fileChooserFrame.dispose();
}
}
});
}
代码示例来源:origin: org.xworker/xworker_core
public static void createActionListeners(ActionContext actionContext){
Thing self = (Thing) actionContext.get("self");
JFileChooser parent = (JFileChooser) actionContext.get("parent");
for(Thing child : self.getChilds()){
ActionListener c = (ActionListener) child.doAction("create", actionContext);
if(c != null){
parent.addActionListener(c);
}
}
}
代码示例来源:origin: onyxbits/dummydroid
@Override
public void edit(FormData formData) {
super.edit(formData);
backwardAction.setEnabled(false);
forwardAction.setEnabled(true);
fileChooser.removeActionListener(this);
fileChooser.addActionListener(this);
}
内容来源于网络,如有侵权,请联系作者删除!