manual swing data binding - java

I have rather big swing interface (several textboxes, comboboxes, checkboxes, custom popup dialogs etc) and a data model that has to be changed when ui control changes: new text is entered into text box, check box is clicked, etc.
The question is: what is the best practice to organize update+validation of input values.
Unfortunately I can not use binding framework like beansbinding.

Add appropriate listeners to the components, and update the model when the events are fired.
Or design your UI so that everything is saved to the model only when a Save or OK button is clicked. This also helps with validation, because you just need to validate everything at once, when the button is clicked.

Combine the answer of JB Nizet with validation in your components, for example by using JFormattedTextField (or an enhanced version of this). You can use the JFormattedTextField also as editor for JComboBox instances. You can add validation to JSlider instances.
In short, provide immediate feedback to the user when he types in an invalid value. That combined with validation on the model side makes a good application.
This can be compared to a modern website: client-side validation with javascript to give the user immediate feedback + server-side validation for validation which does not go through the UI, or to avoid nasty users bypassing your client-side validation

Related

How to highlight an updated component in short time

When user logs into the swing application, and if any new/existing components are introduced/modified, those components need to be highlighted.
So my question is: What's the best way to achieve this? It should be a generic solution as in every release/delivery, I have to use this feature.
I tried the below post below post,
swing - short-time highlight of a component
Whenever the new release happen, to notify the user this is modified/new changes.To indicate user this is new changes.
enter image description here

GWT- PopupPanel with search?

I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?
You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.

How to submit autocomplete select value into Textfield in Tapestry5?

I've got a Textfield with autocomplete and zoneUpdater mixins. Based on the typed value, I call service which returns new values for the autocomplete select. So far, so good. Big problem for me is that autocomplete select doesn't submit chosen value. I want to update different zone, based on this value. The way it works now is that I have to submit the whole form and reopen again. But that's not what customer wants, it should do it on fly without submitting the form. Is there any solution for this? Thank you.
I want to update different zone, based on this value.
I 've tried to do this with your setup and actually worked but the drawback is that the value I get as the CHANGE event of the input is what the user typed (not what the user selected from the autocomplete list).
To get the value from selected from the autocomplete list (although I 've not tried it) you should use the callback parameter of prototype's Autocompleter. Take into account that in order to do this you should rewrite a new Autocompleter mixin of your own as the Tapestry's built-in autocomplete mixin is not honoring that callback parameter.
I 've also checked out the tapestry-jquery's Autocomplete mixin and although jquery's autocomplete supports a autocompleteselect event tapestry-jquery is not handling it in it's instantiation.
I 've not checked the chenille kit autocomplete mixin which maybe can help you, I really don't know.
As far as I know you should develop your own Autocomplete mixin based on any of these and add to it the selected item event functionality.

Java Autocomplete TextField (Ajax style)

I need to create a JTextField (or any component where I can type something) and it has to offer a list of dynamicaly populated values. When I type a new character, the propositions are updated (Like Ajax does)
One particularity is that the user can only choose a value that was populated. I need that for my users to select an existing city from a database.
What would be the easiest way to make it with Swing ?
Thank you.
You can implements Auto complete ComboBox / JFextField based on standard Java API, there aren't any issues with Focus or Caret nor with performance for largiest Arrays for autocompleted JComboBox and JTextField
I have used the JIDE Common Layer for autocompletion in Java Swing. Take a look at the WebStart demo.
It's free and open source, and if the provided autocompletion options don't quite match what you are trying to do I found it really easy to plug in my own logic.
You can use Swingx.Contains extensions to the Swing GUI toolkit, including new and enhanced components that provide functionality commonly required by rich client applications. Highlights include:
Sorting, filtering, highlighting for tables, trees, and lists
Find/search
Auto-completion
Login/authentication framework
TreeTable component
Collapsible panel component
Date picker component
Tip-of-the-Day component

UI for an intended XSL-FO designer in Java

I intend to write a XSL-FO designer in java for which i need to write an UI. The basic idea is to give the user a work pane wherein he/she can draw rectangles and these rectangles would in turn be associated to field containers in the underlying XSL-FO generator. Once the field container are done, the user should also be able to select any of the rectangles(field containers) created and add components into it. These will in turn be translated into field blocks that fall under the chosen field container.
Till now I have created a simple UI using JFames with mouseListeners hooked to them so that i can have users draw the rectangles on the work area.
Im stuck at the point on how to implement the part where the user selects one of the rectangles created in the previous steps.
Given the intent of the designer, is it possible to accomplish this using Jframes ?
Any pointers/suggestions on how i can achieve the motive of this designer would be of great help !
Please excuse me if any part of this post is noobish. I am one when it comes to UI.
JInternalFrame might be a starting point. You can connect them, as shown here, and add arbitrary components as required.

Categories

Resources