Show/Hide Labels - Adding and Removing vs Setting Visible in GWT - gwt

I suppose this could be a general javascript question, but I have a widget that, by default, has a label. I need a way to have a label-less widget. I currently have a special constructor with a boolean indicating whether or not to show this label.
Instead, if I were to add a method to show/hide this label, would it be better use visibility in CSS, or add/remove the label from its parent?

CSS visibility.
However, if you are using GWT and its other cohorts (smartgwt, gxt), setVisible(boolean), show(), hide() is already crafted into their visual components.
When introducing new visual components, you should simply extend the Widget class or any of its subclasses, in order to make full use of GWT features for your new component. The heavy weight of a GWT class Java features is already segregated by the GWT compiler as fixed costs in javascript code - so you might as well extend the Widget class.
And why would you not use the already existent Label class found in GWT (or smartgwt or gxt) and then use the setVisible (or show() hide()) property methods?

Related

GWT Checkbox Selectable Tree

I'm using GWT 2.5 and am looking for a Tree widget which will allow me to have a multi-selection model controlled by checkboxes adjacent to each TreeNode. Something similar to the JQuery plugin described here with the following results:
As you might expect, I'd hope that checking a box would select all children of the checked node, and if any children are unchecked, you'd get the "half-checked" icon (shown by the "Solutions" node) -- so I'll need a three-state checkbox.
Does this widget exist in GWT already, or would I need to code it myself?
There is no default widget in GWT 2.5 that supports this.
Your options:
Use third-party library
Implement you own widget
I used to implement my own based on CellTree and although it's feasible - it requires lots of work (custom tree model, cell widgets with renderers and value updater-s). If you flexible on choosing libraries - have a look at Smart GWT's checkbox tree.

A gwt dropdown ListBox that can have values manually type in?

Our GWT based application needs a font size selector. Ussually people will want to pick the font size from a set of standard sizes. Sometimes however users will want to manually type in a specific font size like '12.6'. We obviously cannot put ever tenth of a point option inside our font size dropdown so a dropdown that can have any value entered manually would make the most sense.
I was told simple-gwt has a widget called ComboBox but it appears to be meant for an older version of gwt (we are on the latest - 2.4). Suggestbox would work except there is no "dropdown" arrow to popup the suggestions so users who do not want to type the size cannot use it.
Any suggestions? I was surprised this widget was not built into GWT.
The widget to use is the SuggestBox - you may or may not be able to extend it to use a click handler to show a set of default suggestions (there may be a property to allow it) and to use CSS to show a dropdown arrow.
javadoc here: http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/SuggestBox.html
Example here: http://examples.roughian.com/index.htm#Widgets~SuggestBox
I know that Smart GWT and ext-gwt have widgets that provide this kind of functionality, but neither of those libraries are free.
Of course you could always roll your own.
I found this library "Advanced GWT components". It is a free library that has drop in GWT widgets.

j2me form how to define gui properties

i'm new to j2me. how to set form elements (text field ,text box) width,font,alignment and other Gui related properties.
i tried to find solution for setting form background but no success. can you guide me
Firstly, J2ME is a very limited framework.
As far as I can remember if you are just using an item from the basic javax.microedition.lcdui package there is very limited styling available. It allows you to give directives on how to lay the item out on the screen and what the item's appearance mode will be.
An Item is not responsible for where it is placed and is down to the Screens layout management algorithm to place your item on the Screen. For example, the way Items are laid out on Forms and Lists differ based upon how the layout management works.
You can create your own customs items by extending CustomItem and implementing and overriding various functions to get the desired visual effect. This however is a lot of work
and the end result is not always very pleasing. You could also do the same by extending the Form class and overriding the paint methods to get your disered visual effect.
The best way to have control over form elements is to use one of the Widget like frameworks that exist and are built upon these basic J2ME classes. For example LWUIT and J2ME Polish allow you to style items in a very similar manner and layout Items using a CSS box inspired manner.
Although I have no used LWUIT so cannot vouch for it.

Custom component for Label with Text box and image in GWT

I need to create a custom component which can have Label then Textfield and Image, by clicking the image i should select date, that selected date should be populated in TextField,
Is there way i can develop a custom component.
Thanks in Advance!!!
Absolutely!
You need to create a custom widget, and the way to do that is to extend the Composite class.
From the documentation:
A composite is a specialized widget that can contain another component (typically, a Panel) but behaves as if it were its contained widget. You can easily combine groups of existing widgets into a composite that is itself a reusable widget. Some of the UI components provided in GWT are composites: for example, the TabPanel (a composite of a TabBar and a DeckPanel) and the SuggestBox.
Rather than create complex widgets by subclassing Panel or another Widget type, it's better to create a composite because a composite usually wants to control which methods are publicly accessible without exposing those methods that it would inherit from its Panel superclass.
There is a good example to get you started here:
http://code.google.com/webtoolkit/doc/latest/DevGuideUiCustomWidgets.html
The GWT showcase give an example of somthing similar to what you are looking for along with the source code:
"Date Picker" - GWT Showcase
If you want to develop a custom component, look at #Jon Vaughan's answer!
You may also use third party libraries with widgets, like Ext GWT or SmartGWT. Date picker is one of the base widgets that everyone provides.

placing widget in listbox/dropdown in gwt

i am using gwt to build my web site.
i would like to create a dropdown/listbox that contains no just text but also images, meaning that in the drop down there will be a what ever widget that ill create.
please advise
jaimon
You won't be able to do this with a ListBox, because it just creates an HTML < select> element.
You can use a MenuBar that has one menu with MenuItems in it to simulate a dropdown with complex widgets inside it. You will also be able to style the dropdown rather than rely on browser-styled form elements.
Take a look at the Combobox or Suggestion box in Advanced GWT Components.
Another widget is the DropDownListBox in the GWT incubator. I have not used it, but the stated intent is to provide a rich, stylable ListBox. You can pass raw HTML to the addItem() method.
DropDownListBox
it is possible to use Tree inside ScrollPanel, without using nested items
Tree allows TreeItem to be a Widget