I need an Open Dialog File Chooser that opens files for reading only. I want user to only be able to click on a file name to select it with no option to edit the name. Users should be able to browse to other folders, though.
I'm on Ubuntu 10.11 with the latest Java (as of January).
TIA.
This example shows that editable file names is a feature of the FileChooserUI implementation. For example, com.apple.laf.AquaFileChooserUI does not have this capability. The tutorial does not suggest any way that it can be changed, but this FileBrowser may suggest a custom alternative.
Related
I am trying to open a folder from java program by using the following java code
Desktop.getDesktop().open(new File("d:\\abc"));
I can successfully opened d:\\abc, now this abc folder is having two sub folders images, and songs now my reuirement is to focus this folder then open it by depending on user given input at run time.
May be tomorrow these sub file names will be changed, but depending on user input i want to focus on corresponding sub folders and open them.
I tried lot of ways in google and stackoverflow also. But I didn't get proper way.
Use a JFileChooser to display the local file system and get the user's selection. Alternatively, add a suitable list or tree selection listener to one of the display components cited here.
You can use Robot class, by using this Robot class you can press key on keyboard programatically.
If user input is
images
then user Robot class to press corresponding key programatically.
Here you can get tutorial on Robot class
http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html
I have made an android app and I have some .csv files with initial data. Can anyone suggest a proper way to do that? For example, someone could say "just create a folder and put them inside" but I want a better way like a setup that I can do with windows (e.g. installshield but no so advanced ).
You can make with wizard forms. In first window choose .csv file, in second window
match the fileds of .csv file with database fildes and finally upload data.
I have to automate a case in which I have to download an excel file using selenium ide.I have done this in firefox by using custom profile feature which automatically download file and save it into a user defined folder. To do the same in Internet explorer, is there any thing in IE like custom profile and preferences? how do I prompt IE to automatically download a file..I am using java for automation..Kindly help..
No, you can't do it easily in IE, there's no profile to configure.
That said, you can try:
downloading the file directly using this (or any other similar WebDriver-friendly tool), if you can. That will totally cut IE out of the process.
see How to download and save a file from Internet using Java? about the same thing, just generic Java and not WebDriver.
if everything fails, you can try blindly pressing Enter after clicking the download, Robot helps with this. But you can't really specify the folder.
I'm trying to open a PDF file after I generate a report. I mean, the user logs in (it's a Swing-based app) and clicks to generate a report. Then, a PDF file is generated. I would like to launch the PDF reader at that moment. I could do something like exec("evince "+path_to_pdf_file). It's just for Ubuntu, Windows would be more difficult. I'm thinking I need to explore the registry.
How can I achieve this?
What you need is the method java.awt.Desktop#open
Launches the associated application to open the file.
If the specified file is a directory, the file manager of the current platform is launched to open it.
I'm having the following problem with a JFileChooser: I create a save dialog and then when I'm trying to save a file, I'm entering a file name into the field and click "Save". Suppose that the directory, which I try to save my file to, contains a subdirectory, which is named exactly like the entered name. In this case JFileChooser opens it instead of saving my file, and I don't know how to make it save a file instead of opening the directory with the same name.
I tried to do something with the file filters, with approveSelection() and changed UI from Windows to default - nothing helps. How to make JFileChooser stop opening a folder and save the file? Is there some way to modify the behavior of the button or am I just doing something wrong?
Update:
To be clear: I'm not trying to save a file with the same name, I'm just trying to make JFileChooser get the path so I could append an extension to it. However, I checked Word and Photoshop, neither of them is able to do what I request, so I guess I wish to make everything too perfect. But if there's a way to do what I want, I'll still be glad to hear the solution.
Neither Windows nor Linux allow file names and directory names to be the same in the same directory as far as I know. Under Linux of course they can be the same with different case lettering :)