PDA

View Full Version : Toggle Button



ExtJsNoviceMember
15 Jan 2009, 12:24 PM
I do need a feature for Button (Pressed and UnPressed) like a toggle Button. Can some one let me know if it can be done using GXT.

I am using Window as DialogBox having a Custom Button on it and will make a Service Call on clicking the button. I need to display a error message on the same Dialog Box down the Button. Would like to know if there is some thing that is provided by GXT.



Thanks,
Novice Member.

ExtJsNoviceMember
15 Jan 2009, 12:32 PM
Is there a Sample Demo available for Toggle Button Widget?

kolli
15 Jan 2009, 12:37 PM
package com.peoplenet.demo.client;

import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class test implements EntryPoint {

public void onModuleLoad() {
final ToggleButton toggle = new ToggleButton("test");
final LabelField label = new LabelField();

toggle.addSelectionListener(new SelectionListener<ComponentEvent>(){
@Override
public void componentSelected(ComponentEvent ce) {
if(toggle.isPressed())
{
label.setText("button pressed");
}else
{
label.setText("button released");
}

}
});
RootPanel.get().add(label);
RootPanel.get().add(toggle);
}
}


This might help

kolli
15 Jan 2009, 12:49 PM
http://www.extjs.com/explorer/#buttons (http://www.extjs.com/forum/../explorer/#buttons)

kolli
15 Jan 2009, 1:41 PM
well if you go through the api there is togglebutton widget which is what you are looking for .