JavaFX FileChooser subclasses as final from Object, and none of its methods looks promising. It's just a bit annoying from a TDD point of view (end-to-end test). Is the idea just to mock the whole business of choosing a file?
Swing JFileChooser was a proper JComponent: you could dig into it, mess around with it, subclass it, etc. With FileChooser I don't even see how we could get a Robot or JavaFX framework to select things, press buttons, etc. Seems a bit ... monolithic.
Related
Is there any Java code can help to detect another program GUI part by part?
For example, detect the size of the GUI, detect the location of the button.
Selenium does something similar to this but it is really not there. It will work only for browser-based apps/programs/sites. But if your target programs are browser-based, it will probably be a great tool.
For desktop programs, you might give a look to the createScreenCapture(Rectangle) method from the java.awt.Robot class to get a BufferedImage with the contents of the screen, and then it is up to you to try to make sense of the image, which would not be easy. Also, you might use the Robot to try to juggle out windows as needed, press buttons, type text, or whatever is needed to find out what you want. All of this will be a lot of work.
I have been trying to use a datatable that I create dynamically inside a dialog. Each row has a checkbutton and an editbox. When I try to use a DOJO dialog, I can update the properties in the java object associated with it, but the same button doesn't seem to close the dialog in any way i try it.
I have also tried using a jquery dialog but I had problems with the partial updates, I couldn't fire any server side events from the dialog.
I have also tried using a repeat control but it generated other problems.
Using java beans to separate the control portion of the code from the view seemed like a very good idea when I saw some forum posts about it, but now it is creating a lot of little problems increasing development time. If anyone has other approaches other then the ones I tried, I would really appreciate it.
Some of the problems related to my question was due to the fact checkBox controls use strings to trueor false instead of actual booleans. And that seemed to make all events not work on the dialog.
Have you tried using the dialog control from XPages Extension Library?
I wrote a workaround for vanilla dojo dialogs a couple of years ago. Not sure if it still works:
http://dontpanic82.blogspot.no/2010/02/xpages-making-dojo-dialogs-works-with.html
I tend to use the Extension Library for most Dojo widgets. This way I don't have to figure out why something doesn't work/I don't have to maintain the code when a new version of XPages/Dojo is released.
is there a way to open a program, that usually opens a new jframe, into an existing jframe?
here is the explanation, I have downloaded a java game one of those reflexes ones and it opens in a jframe with a bunch of sub panels inside of the frame, what i want to do is wrap the existing jframe in another frame or canvas or something so i can build internal scripts for it as apposed to building external scripts that require screenshots and getting pixel data. by internal scripts i mean scripts that run inside the new jframe
The usual way to achieve custom functionality would be to extend the class and override methods to add new/altered components and & new/altered methods.
OTOH I doubt that someone who refers to Java code as 'internal scripts' has the experience needed for this task. It would be better to start with simpler goals.
Has anyone come across a fully customizable (compatible with all standard LnF), fast file browser component for Java Swing ?
I should be able to place this component to Netbeans UI palette and drag and drop in to any JPanel while designing the UI. Also it should support directory, single file, multiple file selection along with file type filtering.
There must be something because I have seen this in applications like jEdit etc.
Note that I am not asking about a dialog box like JFileChooser instead a browser/explorer/tree-view like component.
Here's a relatively simple file system browser built in a JPanel:
File Tree
Here are a few more complex examples of a file browser with icons, popup menus, and tooltips.
These are all built in a JFrame:
File Tree with Icons
File Tree with Popup Menu
File Tree with Tooltips
These examples probably aren't as customizable as you may want, but they're a pretty good
starting point for adding new functionality.
For further reading, Swing, Second Edition (Chapter 17) walks through implementing a JTree component for browsing your file system complete with lazy loading, custom renders, popup menus, and tooltips.
If you'd like to see just the source, you can get it here.
There is also the FileBro that you may want to take a look at. Perhaps you can use it, or at least borrow implementation details.
FileBro
see DJ Project:
http://djproject.sourceforge.net/ns/index.html
I've a request to make some changes to a little applet that currently use a JFileChooser.
One of the main complaints is that the file chooser is a pain in the ass to use because it behaves differently than the native widget, especially for navigating up to the root level.
So, knowing that and all the other issue JFileChooser suffer (like the zip file caching on windows...), I was wondering that a viable alternative exists in the java world.
Of course, there is SWT that use the native widget, but increasing the applet size by 25 is not really an option. So, is there a better pure java implementation of a file chooser?
The AWT FileDialog actually does use the native component, but as with most AWT vs. Swing issues, it's much less flexible and customizable than Swing's JFileChooser. So there's a tradeoff: JFileChooser may have a clunky user interface, but it's usually better for most purposes. If you really want your file choosing dialogs to look and feel like the native ones, though, then you can go with FileDialog.
I know this is a little late, but it may help other users. You can customize the UI of an application to the UI of the OS:
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {e.printStackTrace(); }
You can also try XFileDialog. Haven't tried it much yet but looks worth evaluating.
I wrote a wrapper around JavaFX' file chooser if available. If included in your application, you can replace
JFileChooser fileChooser = new JFileChooser();
with
JFileChooser fileChooser = new NativeJFileChooser();
It will then use the native (and modern) file chooser of the underlying platform. Not everything works 100% the same, so make sure to test it afterwards, but most things should go smoothly.
As #htw said use FileDialog if the look and feel is your main concern. By using FileDialog be aware that there a lots of convenience methods that you won't be able to use...
I used VFSJFileChooser few times. It doesn't suffer from the JFileChooser bugs(slow to load because of zip files, windows only), but the interface is not "native".