When using the standard dir dialog box from MATLAB uigetdir, double-clicking on a directory leads to the dialog box entering it and displaying its contents. To actually select it, you have to click on the "select directory" button.
What I would like is a way to add specific rules on what to do when double-clicking on a directory : basically, I would like to change/override the internal 'method/callback' associated to this action.
Problem is, said dialog box is NOT your usual Matlab figure - that I would know how to do easily (retrieve the handle, look at properties and edit/modify the corresponding callback). This looks like a raw Java object and I find no way to access this information from Matlab.
Thanks for your help.
You could try this, instead of uigetdir:
fc = javax.swing.JFileChooser('/initial/path')
% then customise the dialog using Java methods, as you please!
fc.setFileSelectionMode(javax.swing.JFileChooser.FILES_AND_DIRECTORIES)
chosenfile = fc.showOpenDialog([])
You could even add listener callback to handle specific events if needed.
Related
In windowsbuilder, I would like to change information from a seperate window, more specifically a table, from my main window. Is it possible to use my information from one seperate window to change it in another box?
Basically, take information from here:
And put it into this table:
Is it possible? If so, how? Thank you in advance.
Yes, it is possible - but not in Windows Builder.
Create an object which will hold the information from the first window and pass the information from the window to the object. Next, pass the object to the second window (how you do this will depend on how you've configured your window objects). Finally, populate the table with the information from the object.
As far as I know, there is no direct way to do this in Windows Builder, although the above method will work fine provided you can pass objects from the first window to the second.
I need to provide a java widget that provides users with a subset of the controls that a JFilechooser provides. Specifically I need to provide the look and feel of a JFileChooser dialog for the following typical actions:
Save Action
Load Action
But I am allowing them to see and do only the following:
See a static list of names that has nothing to do with File objects (These are names pulled from a mysql table).
Change the name so it doesn't conflict with a name they can see from within the static list.
Select a name from the static list
Ok
Cancel
So really just a way to do the basic things you can do with a JFileChooser minus the directory navigation and creation. Does such a skeleton of the JFileChooser exist or do I need to create this from scratch?
Thanks.
-Dennis
I would like to, if it is possible, to open MATLAB figure, generated in MATLAB function, on JButton click. (Maybe to add it to a JFrame or something like that.)
So far I done these steps:
in MATLAB: create m-file, add it to a java package project, build it with MATLAB Builder JA;
in Eclipse: create new project, import files, create GUI and on button click call matlab function to do all necessary calculation...and with setText write results in textFileds.
but how can I show figures on button click and is it possible at all?
It would be simplier if you use the matlab GUI (which uses JButton). You can use findjobj
to get the JButton object inside the matlab interface for the uicontrol('Style','pushbutton').
But, if you don't want to do so, you could use JMI. This article gives you some information about it. His book may be very useful for you.
Is there a way to use something like a JFileChooser object to select a computer on the network, rather than a file or a directory?
I need to be able to pull up a chooser panel of some sort, browse to a list of servers on the network, and select the one I want to connect to.
You can provide additional things for selectin in a JFileChooser if you pass a customited FileSystemView to its constructor. I guess it should be possible to use jCIFS to implement a version which presents network hosts under a different root called “Network”, or something like this. You might be able to delegate many methods to the default file system view.
If you don't want to fake the file system itself, you'll have to either create your own dialog or find the correct hooks to modify an existing JFileChooser to custmize it to your needs, either by subclassing and overriding specific methods, or by navigating the component hierarchy and replacing certain components, or by a combination of these two. Sounds no less hackish than the faked file system view, so I'd go for that first, see if it works.
If you really only want to select computers, and won't navigate down the paths to actual files on these computers, then a file chooser is probably overkill, and a JOptionPane would probably be better suited. You can use it to display an input dialog which shows a list of values to select from. Or if you want more control, you can create your own JList and pass that as the message argument for the input dialog.
currently im building an application which is supposed for some sound processing. I'm doing this in java/eclipse with swt/jface.
The processing itself need some options/properties for the algorithem inside. At this time, i have a .properties file which holds all options like:
trimLeadingSilence=20
trimtrailingSilence=20
trimhold=5
fftFrameSize=512
...
I don't want the user to edit these options in a texteditor like notepad++, but within the gui of my app.
Now I think about how to do this. I have 2 "ideas":
Create a class for each option set, and manualy code all these boring gui code lines. Like here for just one option ;-)
Spinner spinnerSilenceBack = new Spinner(shell, SWT.BORDER);
spinnerSilenceBack.setMinimum(0);
spinnerSilenceBack.setMaximum(200);
selection = Integer.valueOf(PropertyManager.getPropertyValue("trimming", "trailingSilence"));
spinnerSilenceBack.setSelection(selection);
spinnerSilenceBack.setIncrement(5);
spinnerSilenceBack.setPageIncrement(20);
spinnerSilenceBack.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int selection = ((Spinner) e.getSource()).getSelection();
int digits = ((Spinner) e.getSource()).getDigits();
int result = (int) (selection / Math.pow(10, digits));
PropertyManager.setPropertyValue("trimming", "trailingSilence", String
.valueOf(result));
}
});
This takes a lot of time due to the fact that there are a lot of different options. So I thought about how I can dynamicly create such gui code, or just dynamicly create these gui windows when starting up the application. At least I would need a config file for the "gui creator" but I don't want to reinvent such a thing-thats why i ask you guys :)
I couldn't get clearly what you are asking.
But, since your question was How to dynamicly build up a gui, i have a a suggestion:
You could use Java Template Engine
library like Freemarker. This
would help you create GUI's that can
be built to work on the fly. With
freemarker you can have one single
template file and then replace the
values accordingly.
I have used it to generate HTML files on the fly. You could evaluate if you can use it otherwise. The API Documentation is rich. So you could go through that once.
Do you mean, you want to make an UI which will have all options you specified? It doesn't matter its a form OR a menu, its up to you. But yeah you can surely configure the names and types in .properties file.
See, you build a Menu OR form in AWT/Swing OR Servlet, but you can read it from properties file right?
You can also configure the same using Spring bean XML definitions, which can provide more support like you can specify all details in some Map OR List etc...
thanks.
I didn't use Swing for a lot of time, so here is just a basic principle.
Config should be done in xml, .properties file is bad here, cuz it doesn't describe objects out-of-the-box.
Add button ("Apply config"), attach actionListener, which 1)parses xml config, 2)then creates form or change settings of existing form, textarea, colors etc.
example for xml config:
found - check it's x_coordinate, y_coord (or use layoutManager, depends on logic), action, than jframe.getLayout().add(new Button(x_coord, y_coord, action).
found - the same.
than jframe.setVisible(true);