tags:

views:

90

answers:

3

Hi there,

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 :)

A: 

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.

dkris
I will rework my question. :)
InsertNickHere
But I hope this was of any help to you
dkris
Yes it looks interesting, but I have to read a lot to see if it fits my needs, and i dont have the time to to right now.
InsertNickHere
A: 

Hey,

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.

Paarth
I have reworked my question
InsertNickHere
A: 

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);

foret