lwuit container - lwuit

I have added a container named btnBar with boxlayout(x-axis) on a form. the container has 4 buttons of custom class MyButton that extends from Button itself. When i add actionlistener to one of the buttons in the container it gets invoked for each n every button. Even the actionevent.getsource.gettext method returns the same value irrespective of the focus. I have added the buttons through an array and m trying to use is something like this:
btns[0].addActionListener(......)
Where am I going wrong?

got is solved buddies...actually was using setfocus() to traverse within the btnBar on buttons...but needed to use setFocused() method of form too....after setFocus()....dnt hammer ur brains now....

You must never use setFocus, you should use setFocusable to toggle focusability and requestFocus to get the focus to a specific component.
You should also migrate to Codename One, since LWUIT is pretty much unmaintained.

Related

how to bind OnClick event to Singleton function?

I want to bind OnClick event of UI Button to a function in Singleton object. I tried to do that, but every time I go to other scene and get back to the old scene I find that object disappear from the onClick field in the inspector while it's exist in the hierarchy ! If it's not possible to do that, what's the alternative way ?
Note: I'm using c#
Looks like this guy had a similiar problem: http://answers.unity3d.com/questions/335736/gameobject-still-destroyed-after-reloading-level.html
I would have posted this as a comment if I had enough reputation..

LWUIT Container capture event

I have a Containerwith so many Labels added inside it. When I try to capture the pointerReleased event in this Container, I have found some problems. The event only is captured when I released in the free area of the Container, no when I made the release over the Labels. Is there any way to encapsulate this event? I mean when I will do the realase over the main Container(instead I'm on a Label), the event must be launched.
Here you can take a look at my Container
You should look at the lead component feature added in LWUIT 1.5, it allows you to define a component that manages the entire hierarchy of container/component and all events for every component in the hierarchy are sent to it.
This adds another benefit of handling the style synchronization between all the different elements (e.g. if you use a button all components will become pressed together).
I dont' find any cool solution, so finally I propagate the pointerReleased from the Labelsto the Container.

ImgButton : How to tell SmartGWT to not concatene state on the name of file source?

private ImgButton button = new ImgButton();
...
button.setSrc("iconName.jpg");
GWT or SmartGWT, I cannot tell exactly, generate state word to concatene it on the name of file.
Example to clarify :
On focus, iconName.jpg become iconName_Focus.jpg
On mouse down click, iconName.jpg become iconName_Down.jpg
On over, iconName.jpg become iconName_Over.jpg
Because these images are custom images, I want to tell GWT to take a default image when I didn't provide the corresponding image.
For example, when over event is fire and iconName_Over.jpg does not exist then use iconName.jpg.
Use the setShow{State} or setShow{State}Icon methods accordingly. For example for disabling the mouse down state, use setShowDown(Boolean.FALSE). For not showing a different icon when the mouse goes down on the button, use the setShowDownIcon(Boolean.FALSE). The rest of the actions have accordingly named methods you can look up at the ImgButton's javadoc page.

GWT UiBinders Interaction between modules

Im new to GWT, this should be a simple question i hope.
Imagine that i made two Uibinders Modules or two independent widgets.(this a simplify example to expose my problem)
one is a set of buttons (ButtonPanel) and the other image to been show when i press a button from the previous panel(ImagePAnel) with a label to be the title of the image.
How can i reach the wiget the imagePanel to actuate when there are a handler click from the buttons in the (ButtonPanel)
Thanks for the help.
I recommend you to use MVP Pattern for Development and add all events in the Presenter.
Or Else you can use the following technique within the UIBinder's Java File
#UiHandler(value={"openButton"})
public void onOpenButtonClick(ClickEvent clickEvent){
//ADD THE BUTTON LOGIC HERE
}
Just Create an Object of the Images & the ImagePanel to be loaded and add it on button click using this.
I can't say I understand exactly what you are trying to accomplish but in general the best way for different components in a GUI application to communicate is to use the eventbus pattern. There's one global Eventbus object in the application that lets components subscribe to a specified type of event that are fired from any place in your application. This way you avoid spaghetti code and your components are loosely coupled.
http://code.google.com/webtoolkit/articles/mvp-architecture.html#events
I typically create a third component that is the container for the Button and Image components you defined. This component sets itself as a callback for the two and contains logic to integrate the two.

How to render element in gwt?

From last few months I am working on gwt-ext.In that I am using a doLayout() method of Container class.Here is description of it.
Force this container's layout to be recalculated. A call to this function is required after adding a new component to an already rendered container. If you are not dynamically adding and removing components after render, this function will generally not need to be called.
Do this method is basically used to render container.
Now I am using core gwt 2.3. Is there any method to render the container in gwt.or any other way to achieve this ???
Thanks in advance
AFAIK, GWT does not require this. Just call .add() on any Panel to add children. They should be immediately visible.