-
10 Dec 2008 10:18 AM #1
Set width TextArea
Set width TextArea
I need to set to description width = 500, but I dont have successsCode:FormPanel simple = new FormPanel(); simple.setHeading("Simple Form"); simple.setFrame(true); simple.setWidth(350); TextField<String> firstName = new TextField<String>(); firstName.setFieldLabel("Name"); firstName.setAllowBlank(false); simple.add(firstName); TextField<String> email = new TextField<String>(); email.setFieldLabel("Email"); simple.add(email); List<Stock> stocks = TestData.getStocks(); Collections.sort(stocks, new Comparator<Stock>() { public int compare(Stock arg0, Stock arg1) { return arg0.getName().compareTo(arg1.getName()); } }); ListStore<Stock> store = new ListStore<Stock>(); store.add(stocks); ComboBox<Stock> combo = new ComboBox<Stock>(); combo.setFieldLabel("Company"); combo.setDisplayField("name"); combo.setStore(store); simple.add(combo); DateField date = new DateField(); date.setFieldLabel("Birthday"); simple.add(date); TimeField time = new TimeField(); time.setFieldLabel("Time"); simple.add(time); CheckBox check1 = new CheckBox(); check1.setBoxLabel("Classical"); CheckBox check2 = new CheckBox(); check2.setBoxLabel("Rock"); check2.setValue(true); CheckBox check3 = new CheckBox(); check3.setBoxLabel("Blue"); CheckBoxGroup checkGroup = new CheckBoxGroup(); checkGroup.setFieldLabel("Music"); checkGroup.add(check1); checkGroup.add(check2); checkGroup.add(check3); simple.add(checkGroup); Radio radio = new Radio(); radio.setName("radio"); radio.setBoxLabel("Red"); radio.setValue(true); Radio radio2 = new Radio(); radio2.setName("radio"); radio2.setBoxLabel("Blue"); RadioGroup radioGroup = new RadioGroup("test"); radioGroup.setFieldLabel("Favorite Color"); radioGroup.add(radio); radioGroup.add(radio2); simple.add(radioGroup); TextArea description = new TextArea(); description.setPreventScrollbars(true); description.setFieldLabel("Description"); simple.add(description);
-
18 Dec 2008 5:24 AM #2
-
18 Dec 2008 7:07 AM #3
1 point is that the formPanel is set to 350, so you have to increase that size to see the size of description to 500.. and then u have to mention explicitly
description.setWidth(500);
-
6 Jan 2009 6:28 PM #4
GXT TextArea.setWidth not working
GXT TextArea.setWidth not working
I'm piggybacking on this thread because I'm having the same issue in a different context. I'm new to GXT and trying to create a TextArea with a set width. I've tried all the alternatives I can think of for TextArea.setWidth(): "100%", "600px", 600. None of them seem to do anything. Finally, I discovered that by changing the FormLayout's default width, I could get the TextArea width to expand. That actually works for me in this case because I only have a TextArea to display. But I'd like to understand the proper solution to this problem.
Here is a cut-down code sample. This comes out of the constructor of a LayoutContainer.
Thanks for all help.Code:private FormPanel panel = new FormPanel(); private TextArea taNotes = new TextArea(); setLayout(new FlowLayout(6)); // The following doesn't seem to accomplish anything. taNotes.setWidth("720px"); taNotes.setValue("xxxx"); FormLayout fl = new FormLayout(); // However, the following will cause the TextArea to widen. // fl.setDefaultWidth(720); panel.setLayout(fl); panel.setExpanded(true); panel.add(taNotes); add(panel);Guy Rouillier
-
6 Jan 2009 7:47 PM #5
if you are using a FormPanel or the FormLayout on a panel, you need to set this with FormData. Like so...
you need to do this via FormData as the layout is managing the size/position - setWidth is being overriden by the layout manager in this case and is why it doesn't workCode:panel.add(txtfld, new FormData("200")); // sets the width to 200pxGXT JavaDocs: http://extjs.com/deploy/gxtdocs/
GXT FAQ & Wiki: http://extjs.com/learn/Learn_About_the_Ext_GWT_Library
Buy the Book on GXT: http://www.apress.com/book/view/9781430219408
Follow me on Twitter: http://twitter.com/gslender
-
7 Jan 2009 2:31 AM #6
-
7 Jan 2009 11:35 AM #7
gslender, thanks for providing not only the solution but an explanation as well. I'm new to this, so I'm probably doing something wrong, but neither of the following worked for me:
panel.add(taNotes, new FormData("720"));
panel.add(taNotes, new FormData("720px"));
However, the following did work:
panel.add(taNotes, new FormData(720, 400));
So, I'm good to go.Guy Rouillier
-
7 Jan 2009 1:14 PM #8
I'd need to see a full example to be sure/understand why... your code snippet above is too short. Include the entire onModuleLoad etc and keep in contained to just the problem if possible (ie no need having other forms/rpc etc)
GXT JavaDocs: http://extjs.com/deploy/gxtdocs/
GXT FAQ & Wiki: http://extjs.com/learn/Learn_About_the_Ext_GWT_Library
Buy the Book on GXT: http://www.apress.com/book/view/9781430219408
Follow me on Twitter: http://twitter.com/gslender
-
17 Jan 2009 8:45 PM #9
Sorry for the long delay in response, I've been working long hours on a project. Through MyEclipse, I created an empty GWT application, then added in just enough to demonstrate the problem. The entire project zipped up is 40 MB, so hopefully the source will be sufficient.
In NotesPanel.java, using
panel.add(taNotes, new FormData("700px"));
does not set the width of the TextArea, while
panel.add(taNotes, new FormData(700, 300));
does.
Please let me know if you'd like any other parts of this sample. Thanks.Guy Rouillier
-
19 Jan 2009 5:50 AM #10
Well i think that the single argument that you are passing into the formdata is supposed to be a string but it should be something related to the anchor layout
http://extjs.com/deploy/gxtdocs/com/extjs/gxt/ui/client/widget/layout/FormData.html#FormData(java.lang.String)
So i dont think setting a size to formdata as a string works.
The formdata(width, height) is the correct constructor that should be called to set the width and the height of formdata.



Reply With Quote
