本文整理汇总了Java中javax.swing.JFileChooser.setApproveButtonToolTipText方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.setApproveButtonToolTipText方法的具体用法?Java JFileChooser.setApproveButtonToolTipText怎么用?Java JFileChooser.setApproveButtonToolTipText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.setApproveButtonToolTipText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doLoadCalibration
import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doLoadCalibration() {
final JFileChooser j = new JFileChooser();
j.setCurrentDirectory(new File(dirPath));
j.setApproveButtonText("Select folder");
j.setDialogTitle("Select a folder that has XML files storing calibration");
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
j.setApproveButtonText("Select folder");
j.setApproveButtonToolTipText("Only enabled for a folder that has cameraMatrix.xml and distortionCoefs.xml");
setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
j.addPropertyChangeListener(JFileChooser.DIRECTORY_CHANGED_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {
setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
}
});
int ret = j.showOpenDialog(null);
if (ret != JFileChooser.APPROVE_OPTION) {
return;
}
dirPath = j.getSelectedFile().getPath();
putString("dirPath", dirPath);
loadCalibration();
}
示例2: doLoadCalibration
import javax.swing.JFileChooser; //导入方法依赖的package包/类
synchronized public void doLoadCalibration() {
final JFileChooser j = new JFileChooser();
j.setCurrentDirectory(new File(dirPath));
j.setApproveButtonText("Select folder");
j.setDialogTitle("Select a folder that has XML files storing calibration");
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
j.setApproveButtonText("Select folder");
j.setApproveButtonToolTipText("Only enabled for a folder that has cameraMatrix.xml and distortionCoefs.xml");
setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
j.addPropertyChangeListener(JFileChooser.DIRECTORY_CHANGED_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {
setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
}
});
int ret = j.showOpenDialog(null);
if (ret != JFileChooser.APPROVE_OPTION) {
return;
}
dirPath = j.getSelectedFile().getPath();
putString("dirPath", dirPath);
loadCalibration();
}
示例3: allPlatformGetFolder
import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
*
* @param dialogTitle
* @param location
* @return
*/
public static File allPlatformGetFolder(
String dialogTitle,
File location) {
File fractionFolder = null;
JFileChooser fc = new JFileChooser();
fc.setApproveButtonText("Select");
fc.setApproveButtonToolTipText("Select the folder that will contain the Calamari Reports.");
// this moves up one level so we can choose folder
fc.setCurrentDirectory(location.getAbsoluteFile().getParentFile());
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setDialogTitle(dialogTitle);
fc.setSelectedFile(location.getAbsoluteFile());
// Show open dialog; this method does not return until the dialog is closed
int result = fc.showOpenDialog(new JFrame());
if (result == JFileChooser.APPROVE_OPTION) {
fractionFolder = fc.getSelectedFile();
if (!fractionFolder.exists()) {
JOptionPane.showMessageDialog(null,
new String[]{"The folder does NOT exist."},
"ET Redux Warning",
JOptionPane.WARNING_MESSAGE);
}
}
return fractionFolder;
}
示例4: save
import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void save(){
System.out.println("Save");
if(currentFile == null){
System.out.println("Save untitled.");
JFileChooser fileChooser = new JFileChooser();
fileChooser.setApproveButtonText("Save");
fileChooser.setApproveButtonToolTipText("Save in this folder with the given name.");
int returnVal =fileChooser.showOpenDialog(this);
if( returnVal == JFileChooser.APPROVE_OPTION){
File selectedFile = fileChooser.getSelectedFile();
System.out.println("File approved: " + selectedFile);
if(selectedFile.exists()){
throw new IllegalArgumentException("Overwrite unimplemented.");
}else{
forceSave(selectedFile);
System.out.println("Save successfull.");
}
}else{
System.out.println("File not approved: " + returnVal);
}
}else{
System.out.println("Saving opened file");
forceSave(currentFile);
}
}
示例5: load
import javax.swing.JFileChooser; //导入方法依赖的package包/类
public void load(){
System.out.println("Save");
JFileChooser fileChooser = new JFileChooser(currentFile);
fileChooser.setApproveButtonText("Load");
fileChooser.setApproveButtonToolTipText("Load the chosen file into the editor.");
int returnVal =fileChooser.showOpenDialog(this);
if( returnVal == JFileChooser.APPROVE_OPTION){
File selectedFile = fileChooser.getSelectedFile();
System.out.println("File approved: " + selectedFile);
if(selectedFile.exists()){
if(selectedFile.canRead()){
try {
loadFile(selectedFile);
} catch (IOException e) {
throw new IllegalArgumentException("Error loading file.", e);
}
}else{
throw new IllegalArgumentException("Cannot read file");
}
}else{
throw new IllegalArgumentException("File does not exist");
}
}else{
System.out.println("File not approved: " + returnVal);
}
}
示例6: createProjectChooser
import javax.swing.JFileChooser; //导入方法依赖的package包/类
/** Factory method for project chooser
*/
public static JFileChooser createProjectChooser( boolean defaultAccessory ) {
ProjectManager.getDefault().clearNonProjectCache(); // #41882
OpenProjectListSettings opls = OpenProjectListSettings.getInstance();
JFileChooser chooser = new ProjectFileChooser();
chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
if ("GTK".equals(javax.swing.UIManager.getLookAndFeel().getID())) { // NOI18N
// see BugTraq #5027268
chooser.putClientProperty("GTKFileChooser.showDirectoryIcons", Boolean.TRUE); // NOI18N
//chooser.putClientProperty("GTKFileChooser.showFileIcons", Boolean.TRUE); // NOI18N
}
chooser.setApproveButtonText( NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonText" ) ); // NOI18N
chooser.setApproveButtonMnemonic( NbBundle.getMessage( ProjectChooserAccessory.class, "MNM_PrjChooser_ApproveButtonText" ).charAt (0) ); // NOI18N
chooser.setApproveButtonToolTipText (NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonTooltipText")); // NOI18N
// chooser.setMultiSelectionEnabled( true );
chooser.setDialogTitle( NbBundle.getMessage( ProjectChooserAccessory.class, "LBL_PrjChooser_Title" ) ); // NOI18N
//#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
chooser.setAcceptAllFileFilterUsed( false );
chooser.setFileFilter( ProjectDirFilter.INSTANCE );
// A11Y
chooser.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AN_ProjectChooserAccessory"));
chooser.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AD_ProjectChooserAccessory"));
if ( defaultAccessory ) {
chooser.setAccessory(new ProjectChooserAccessory(chooser, opls.isOpenSubprojects()));
}
File currDir = null;
String dir = opls.getLastOpenProjectDir();
if ( dir != null ) {
File d = new File( dir );
if ( d.exists() && d.isDirectory() ) {
currDir = d;
}
}
FileUtil.preventFileChooserSymlinkTraversal(chooser, currDir);
new ProjectFileView(chooser);
return chooser;
}
示例7: getPatchFor
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private File getPatchFor(FileObject fo) {
JFileChooser chooser = new JFileChooser();
String patchDirPath = DiffModuleConfig.getDefault().getPreferences().get(PREF_RECENT_PATCH_PATH, System.getProperty("user.home"));
File patchDir = new File(patchDirPath);
while (!patchDir.isDirectory()) {
patchDir = patchDir.getParentFile();
if (patchDir == null) {
patchDir = new File(System.getProperty("user.home"));
break;
}
}
FileUtil.preventFileChooserSymlinkTraversal(chooser, patchDir);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
String title = NbBundle.getMessage(PatchAction.class,
(fo.isData()) ? "TITLE_SelectPatchForFile"
: "TITLE_SelectPatchForFolder", fo.getNameExt());
chooser.setDialogTitle(title);
// setup filters, default one filters patch files
FileFilter patchFilter = new javax.swing.filechooser.FileFilter() {
@Override
public boolean accept(File f) {
return f.getName().endsWith("diff") || f.getName().endsWith("patch") || f.isDirectory(); // NOI18N
}
@Override
public String getDescription() {
return NbBundle.getMessage(PatchAction.class, "CTL_PatchDialog_FileFilter");
}
};
chooser.addChoosableFileFilter(patchFilter);
chooser.setFileFilter(patchFilter);
chooser.setApproveButtonText(NbBundle.getMessage(PatchAction.class, "BTN_Patch"));
chooser.setApproveButtonMnemonic(NbBundle.getMessage(PatchAction.class, "BTN_Patch_mnc").charAt(0));
chooser.setApproveButtonToolTipText(NbBundle.getMessage(PatchAction.class, "BTN_Patch_tooltip"));
HelpCtx ctx = new HelpCtx(PatchAction.class.getName());
DialogDescriptor descriptor = new DialogDescriptor( chooser, title, true, new Object[0], null, 0, ctx, null );
final Dialog dialog = DialogDisplayer.getDefault().createDialog( descriptor );
dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PatchAction.class, "ACSD_PatchDialog"));
ChooserListener listener = new PatchAction.ChooserListener(dialog,chooser);
chooser.addActionListener(listener);
dialog.setVisible(true);
File selectedFile = listener.getFile();
if (selectedFile != null) {
DiffModuleConfig.getDefault().getPreferences().put(PREF_RECENT_PATCH_PATH, selectedFile.getParentFile().getAbsolutePath());
}
return selectedFile;
}