use of javax.swing.JFileChooser in project yyl_example by Relucent.
the class CertContent2 method registerListener.
/** 注册监听 */
private void registerListener() {
btnKeystore.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = chooser.showOpenDialog(btnKeystore);
if (returnVal == JFileChooser.APPROVE_OPTION) {
txtKeystore.setText(chooser.getSelectedFile().getAbsolutePath());
}
txtCerFile.setText(txtKeystore.getText() + ".cer");
fillJComboBox();
}
});
cboAlias.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Object oItem = cboAlias.getSelectedItem();
String sAlias = oItem == null ? "" : String.valueOf(oItem);
txtCerFile.setText(txtKeystore.getText() + "_" + sAlias + ".cer");
}
});
btnDisplay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
sCommand = getCommand();
txtDebug.setText("");
txtDebug.append(sCommand);
}
});
btnExecute.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtDebug.setText("");
new ExecuteCommand(txtDebug).execute(sCommand, null);
btnExecute.setEnabled(false);
fillJComboBox();
}
});
}
use of javax.swing.JFileChooser in project yyl_example by Relucent.
the class CertContent3 method registerListener.
/** 注册监听 */
private void registerListener() {
btnKeystore.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = chooser.showOpenDialog(btnKeystore);
if (returnVal == JFileChooser.APPROVE_OPTION) {
txtKeystore.setText(chooser.getSelectedFile().getAbsolutePath());
}
}
});
btnDisplay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
sCommand = getCommand();
txtDebug.setText("");
txtDebug.append(sCommand);
}
});
btnExecute.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtDebug.setText("");
new ExecuteCommand(txtDebug).execute(sCommand, null);
btnExecute.setEnabled(false);
}
});
}
use of javax.swing.JFileChooser in project yyl_example by Relucent.
the class CertContent4 method registerListener.
/** 注册监听 */
private void registerListener() {
btnKeystore.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = chooser.showOpenDialog(btnKeystore);
if (returnVal == JFileChooser.APPROVE_OPTION) {
txtKeystore.setText(chooser.getSelectedFile().getAbsolutePath());
}
}
});
btnCerFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) {
return (f.isFile() && f.getPath().endsWith(".cer"));
}
public String getDescription() {
return ".cer";
}
});
int returnVal = chooser.showOpenDialog(btnCerFile);
if (returnVal == JFileChooser.APPROVE_OPTION) {
txtCerFile.setText(chooser.getSelectedFile().getAbsolutePath());
}
}
});
btnDisplay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
sCommand = getCommand();
txtDebug.setText("");
txtDebug.append(sCommand);
}
});
btnExecute.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtDebug.setText("");
new ExecuteCommand(txtDebug).execute(sCommand, new String[] { "y" });
btnExecute.setEnabled(false);
}
});
}
use of javax.swing.JFileChooser in project pcgen by PCGen.
the class Initiative method saveToFile.
//** End Preferences Functions **
//** IO Functions **
/** Calls up a file save dialog, and if a file is selected/created, will then save the combatants out to disk. */
public void saveToFile() {
JFileChooser fLoad = new JFileChooser();
File defaultFile = new File(PCGenSettings.getPcgDir());
if (defaultFile.exists()) {
fLoad.setCurrentDirectory(defaultFile);
}
String[] fileExt = { "gmi", "init" };
FileFilter sff = new FileNameExtensionFilter("GMGen Initiative/Encounter Export", fileExt);
fLoad.addChoosableFileFilter(sff);
fLoad.setFileFilter(sff);
final int returnVal = fLoad.showSaveDialog(this);
try {
if (returnVal == JFileChooser.APPROVE_OPTION) {
String fileName = fLoad.getSelectedFile().getName();
String ext = "";
if (!fileName.endsWith(".gmi")) {
ext = ".gmi";
}
File xml = new File(fLoad.getSelectedFile().getParent() + File.separator + fileName + ext);
if (xml.exists()) {
int choice = JOptionPane.showConfirmDialog(this, "File Exists, Overwrite?", "File Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (choice == JOptionPane.YES_OPTION) {
SettingsHandler.ensurePathExists(xml.getParentFile());
saveToDocument(xml);
}
} else {
SettingsHandler.ensurePathExists(xml.getParentFile());
saveToDocument(xml);
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Error Writing File");
Logging.errorPrint("Error Writing File");
Logging.errorPrint(e.getMessage(), e);
}
}
use of javax.swing.JFileChooser in project pcgen by PCGen.
the class DiceBagPluginController method fileOpen.
/**
* <p>
* Displays a file-open dialog box and processes the selected values.
* </p>
*
* @return {@code boolean} indicating success/failure of operation.
*/
public boolean fileOpen() {
boolean returnValue = false;
String sFile = SettingsHandler.getGMGenOption(DiceBagPlugin.LOG_NAME + ".LastFile", System.getProperty("user.dir"));
JFileChooser open = new JFileChooser();
if (sFile != null) {
File defaultFile = new File(sFile);
if (defaultFile.exists()) {
open.setCurrentDirectory(defaultFile);
}
}
String fileExt = "dbg";
FileFilter ff = new FileNameExtensionFilter("GMGen Dice Bag", fileExt);
open.addChoosableFileFilter(ff);
open.setFileFilter(ff);
if (open.showOpenDialog(GMGenSystem.inst) == JFileChooser.APPROVE_OPTION) {
openFile(open.getSelectedFile());
returnValue = true;
}
return returnValue;
}
Aggregations