This may seem like a stupid question, but I need to know where the images used for JFileChooser are located. By images, I mean the image of a file or folder next to the file name.
Here is a picture if you don't understand.
http://i.imgur.com/Ro9bc.png
Thank you.
FileSystemView.getSystemIcon(File)
See File Browser GUI for example code.
Related
I have developed a swing application that displays images, so I have a large amount of images (more than 1500), I'm asking what is the best way to add these images to the swing project, is it just inserting the images in a specific package, or is it better to add a zip file containing the images, or ...?? Thanks in advance
The "right" answer here depends on what you plan to do with the images. If you're using them as icons, you might want to externalize those into a zip file or even a directory structure you ship with the app so they can be swapped out if you ever find the need. A zip file is pretty easy to access from code, and you can even organize it like a java source / package structure and drop it on the classpath so you can load the images with getClass().getResourceAsStream("whatever"). That has the advantage of not conflating actual source code with resource files like images.
Basically I want to deliver a java code which can only be viewed, neither edited or used any other way. Is it possible.
Note: This is not about delivering the .class file. The client wanna see the code in .java file.
Regards
It's not possible.
You can set file as read only. But the viewer can also change permission!.
If they can read it they can copy it. You could make it harder by sending the file as a set of PNG or JPEG screenshots, forcing them to retype (or use a good OCR program). If you are required to let them read the Java code, then they can make a copy.
There's nothing you can do about it.
I have a program that perform two functions: Upload image, Export image.
after uploading an image it will shown in a jLabel,
my question : is there any way to save this image and export it to a new folder on desktop or any place the user choose?
for example, if I uploaded an image and its displayed on jLabel, when I press the Export button the program should open a dialog window asks me to choose a name for a folder and save the image in it.
Thanks in advance!
It sure is possible!
Take a look a JFileChooser, ImageIcon, and ImageIO and specifically search around for tutorials on using ImageIO
I need to make a java program which takes a directory of images and displays them one at a time - Fair enough. However, alongside this picture viewer I need a text box in which the user may comment about this individual picture. This should then be saved to the image so that if I ended execution and re-run the program loading the same directory again the comment attached to the specific image remains. Similarly if I move on to a different picture and come back the comment remains.
I know this can be achieved in multiple ways but im not sure how to best approach it.
Does anyone have an advice for me? All help is greatly appreciated
Thanks :)
Are you looking for EXIF ? This works with TIFF, JPEG, PNG and other common image formats. It looks a better fit to your requirements than dealing with XML files containing the image metadata.
I need to know how can i save text from a javax.swing.JTextArea using javax.swing.JFileChooser. I tried different things but i am not able to save the data from the JTextArea. And also copy from one text file to another using JFileChooser. Please help, I am relatively new to java.
Look at the Basic I/O lesson of the Java Tutorial with particular attention to Reading, Writing, and Creating Files.
For more specific advice, you would need to ask more specific questions, or any questions, for that matter.
JTextArea has read(...) and write(...) methods that you should be using.
A JFileChooser is just for getting the file name and has nothing to do with file I/O.
Copying data is a different story and Andrew has given you links to the tutorial on using file I/O.