Saturday, April 27, 2013

Re: New To GWT: Objects in composite object not aligned correctly

Hello,

May be try to use UIBinder and use HTMLPanel so you can have a good control over the HTML that is generated. That is what I'm doing since Horizontal and Vertical panels are built with table.
Using HTMLPanel with table gives you a cell per cell control.

Boris


2013/4/25 Chris Brown <chris.brown.spe@gmail.com>
I created a composite object for a date range that is supposed to be all bottom aligned. My text boxes are not aligned with my listbox and it's driving me crazy. Thanks for the help.


import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

public class YearWeekInput extends Composite{

ListBox listBox;
YearWeekPanel fromPanel;
YearWeekPanel toPanel;

public YearWeekInput() {

HorizontalPanel mainPanel = new HorizontalPanel();
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
mainPanel.setSpacing(5);
mainPanel.add(getListBox());
mainPanel.add(getFromPanel());
mainPanel.add(getToPanel());

initWidget(mainPanel);
setStyleName("year-week-input");
}

private ListBox getListBox(){

if(listBox == null){
listBox = new ListBox(false);
listBox.setVisibleItemCount(1);
listBox.addItem( "Year/Week Single");
listBox.addItem("Year/Week Range");
}

return listBox;
}

private YearWeekPanel getFromPanel(){

if(fromPanel == null){
fromPanel = new YearWeekPanel("From");
}

return fromPanel;
}

private YearWeekPanel getToPanel(){

if(toPanel == null){
toPanel = new YearWeekPanel("To");
}

return toPanel;
}

private class YearWeekPanel extends Composite {

private TextBox year;
private TextBox week;

public YearWeekPanel(String title) {

VerticalPanel mainPanel = new VerticalPanel();
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
mainPanel.setBorderWidth(0);

mainPanel.add(new Label(title));
mainPanel.add(getTextFields());

initWidget(mainPanel);
setStyleName(title + "-year-week-panel");
}

private Panel getTextFields(){

HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
hPanel.setSpacing(2);

hPanel.add(getYearTextBox());
hPanel.add(getWeekTextBox());

return hPanel;
}
private TextBox getYearTextBox(){
if(year == null){
year = new TextBox();
year.setWidth("4em");
}
return year;
}
private TextBox getWeekTextBox(){
if(week == null){
week = new TextBox();
week.setWidth("2.5em");
}
return week;
}
}
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment