PDA

View Full Version : How to force TextField to be displayed...



marcinKozlowicz
3 Sep 2008, 1:06 AM
How to force TextField to be displayed on component which is too small?
I would like to display a lot of fields in a window which too small to display all of them
I think there should be any possibility to set horizontal Scroll but i can't do it:/
Maybe there is any combination of panels/layouts which can make it but unfortunetly
i couldn't find it.

Thanks in advance.



package example.example.client;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* * Entry point classes define <code>onModuleLoad()</code>.
*/
public class App implements EntryPoint {
/**
* * This is the entry point method.
*/
public void onModuleLoad() {
final Button testButton = new Button("Test");
testButton.addSelectionListener(new SelectionListener<ComponentEvent>(){

@Override
public void componentSelected(ComponentEvent ce) {
final Window modalWindow = new Window();
final ContentPanel panel = new ContentPanel();
panel.setLayout(new FlowLayout());
panel.setHeaderVisible(false);
panel.setScrollMode(Scroll.ALWAYS);

final FormPanel fPanel = new FormPanel();
fPanel.setHeaderVisible(false);
TextField<String> text1 = new TextField<String>();
text1.setFieldLabel("Label1");
TextField<String> text2 = new TextField<String>();
text2.setFieldLabel("Label2");
fPanel.add(text1);
fPanel.add(text2);
panel.add(fPanel);

modalWindow.setModal(true);
modalWindow.setHeight(150);
modalWindow.setWidth(300);
modalWindow.add(panel);
modalWindow.show();
}

});
RootPanel.get().add(testButton);
}


}

posta07
3 Sep 2008, 3:31 PM
Try setting the field width (and/or label width) on the form Panel:


final FormPanel fPanel = new FormPanel();
>>>>>>> fPanel.setFieldWidth(100);


fPanel.setHeaderVisible(false);
TextField<String> text1 = new TextField<String>();
text1.setFieldLabel("Label1");
TextField<String> text2 = new TextField<String>();
text2.setFieldLabel("Label2");
fPanel.add(text1);
fPanel.add(text2);
panel.add(fPanel);

marcinKozlowicz
3 Sep 2008, 11:28 PM
Hi, I know i can reduce field width by setFieldsWidth() method, but i want to
find how to display fields when they don't fit into parent panel.

posta07
4 Sep 2008, 4:51 AM
Have you tried using a different Panel/layout instead of FormPanel?

Like, VerticalPanel? or TableLayout?