I have added a Label and a ListBox in a HorizontalPanel as a header of a web page. When I set the left margin of a label and the right margin of a listbox and change the size of the window, their positions change. It would be great if anyone can help me to solve this problem.
HorizontalPanel hp = new HorizontalPanel();
Label label = new Label("Test Program");
label.addStyleName("test-label");
ListBox listbox = new ListBox();
listbox.addItem("test1");
listbox.addItem("test2");
listbox.addStyleName("test-listbox");
hp.add(title);
hp.add(language);
CSS file:
.test-label{float:left}
.test-listbox{float:right}
I tried you code setting the HorizontalPanel to a 100% width. I tried adding margins to the elements and they work fine. Please note i suspect your vanish behaviour might be due to rogue additions
**hp.add(title);**
**hp.add(language);**
Your declarations have label and listbox and you are adding title and language.
Sample Code :
HorizontalPanel hp = new HorizontalPanel();
hp.addStyleName("testWidth");
Label label = new Label("Test Program");
label.addStyleName("test-label");
ListBox listbox = new ListBox();
listbox.addItem("test1");
listbox.addItem("test2");
listbox.addStyleName("test-listbox");
hp.add(label);
hp.add(listbox);
RootPanel.get().add(hp);
CSS
.test-label {
float: left;
margin-left: 10px;
}
.test-listbox {
float: right;
margin-right: 10px;
}
.testWidth{
width: 100%;
}
Related
I have just 1 FlowPanel & 1 InlineHTML, the following code doesn't make InlineHTML go into the middle of FlowPanel.
myFlowPanel.setWidth("100%");
myFlowPanel.add(myInlineHTML);
myInlineHTML.setHTML("<table>...</table>");
myFlowPanel.addStyleName(getView().getRes().css().textAlignCenterImportant());
//This is css
.textAlignCenterImportant{
text-align:center !important;
}
How can we centralise the myInlineHTML inside myFlowPanel (GWT) by just using 1 FlowPanel & 1 InlineHTML without using other extra widgets?
This css will solve your problem. Apply it on InlineHTML.
.center_text {
display: block;
text-align: center !important;
}
InlineHTML in converted into <span> tag in HTML.
Here is the sample code:
FlowPanel fixHeaderPanel = new FlowPanel();
fixHeaderPanel.setWidth("100%");
InlineHTML inlineHTML=new InlineHTML("Hi how are you!");
inlineHTML.setStyleName("center_text");
fixHeaderPanel.add(inlineHTML);
Snapshot:
EDIT
as per your last comment.
try this one:
inlineHtnl.setHTML("<table width='100%'>..</table>");
I need to place several DatePicker widgets into the row. If there is not enough width to place all of them the rest widgets shift to the next row. It is the default HTML layout behavior. So I am trying to use FlowPanel. With any other widgets (Buttons, Labels, ...) everything ok, but DatePickers are placed one widget to the row. Here's the code
FlowPanel panel = new FlowPanel();
DatePicker picker1 = new DatePicker();
DatePicker picker2 = new DatePicker();
panel.add(picker1);
panel.add(picker2);
RootPanel.get().add(panel);
Any suggestions to solve this problem?
Thanks.
DatePicker's root element is a table so you'd have to give it a display: inline-table style, or put it in an element with display: inline-block style.
The following shouldn't break any other use of DatePicker, but won't work in IE 6 or 7; it's the Simplest Thing That Could Possibly Workâ˘:
.gwt-DatePicker { display: inline-table; }
If you really need IE 6/7 support, you could try the following, in a CssResource:
#if user.agent ie6 {
.gwt-DatePicker { display: inline; }
}
#else {
.gwt-DatePicker { display: inline-table; }
}
I'm using GWT 2.4. I have a view with some simple content ...
final Image ajaxImage = new Image("loading.gif");
final Grid grid = new Grid(1, 2);
grid.setText(0, 0, "Loading...");
grid.setWidget(0, 1, ajaxImage);
this.container = new FlowPanel();
this.container.add(grid);
rootPanel = new SimplePanel();
rootPanel.add(this.container);
I would like this content to be centered horizontally and vertically in the containing panel, which is a FlowPanel, if that matters. How do I do that?
Thanks, - Dave
I know how to do it in a verticalpanel.
VerticalPanel panelPrincipal3 = new VerticalPanel();//Esto es el panel central, donde se centra todo
panelPrincipal3.setWidth("100%");
panelPrincipal3.setHeight("100%");
panelPrincipal3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
panelPrincipal3.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
panelPrincipal3.add(/*your panel*/);//here yo add whatever yo want, and should be centered
if you were to put your FlowPanel as a direct child of your RootPanel, you can try to set its height to 100%. so if you only have a grid as a child component for your container, you can set its alignments like this:
container.setCellHorizontalAlignment( grid, HasHorizontalAlignment.ALIGN_CENTER );
container.setCellVerticalAlignment( grid, HasVerticalAlignment.ALIGN_MIDDLE );
But if you ever change your mind and you'll switch to UiBinder, you can do something like this:
<g:VerticalPanel spacing="0" width="100%" height="100%" ui:field="mainPanel">
<g:Cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
<!-- content goes here -->
</g:Cell>
</g:VerticalPanel>
with css? margin:0 auto; and position:absolute; top:50%; ?
I'm creating a MenuBar, and I want to have it display a little icon when there are sub-elements to be displayed. I thought I could achieve this like so:
interface ActionHeroResources extends ClientBundle, MenuBar.Resources
{
#Source("actionhero.css")
public ActionHeroCSS css();
#Override
#Source("agw-dropdown.png")
ImageResource menuBarSubMenuIcon();
}
private static final ActionHeroResources RESOURCES = GWT.create(ActionHeroResources.class);
MenuBar actionMenu = new MenuBar(true, RESOURCES);
public ActionHero()
{
actionMenu.addItem("Select", aSelectMenuFullOfOptions);
}
But the menu appears with the word "Select" an no icon! I'm positive my ImageResource is working correctly because I use menuBarSubMenuIcon().getURL() from the same resource later, and my image shows up just as you'd expect. In the HTML generated by GWT, there is absolutely no distinction between the items with MenuBars as children and the items with Commands. My CSS is working fine.
Any thoughts?
Try overriding the CSS style for .gwt-MenuBar-vertical .subMenuIcon-selected, like this:
.gwt-MenuBar-vertical .subMenuIcon-selected {
background: none;
}
I use this for my own selected items and it works great:
.gwt-MenuBar-vertical .subMenuIcon-selected {
background: url(images/hand_pointer.png) no-repeat 0px 0px;
}
The problem was ultimately that the popup panels that form the submenus take their stylename from the parent, but append a dependent stylename. I don't know of a way to predict what that dependent stylename will be, since the original stylename is obfuscated. I worked around this problem by using the more generic .gwt-MenuBar popup stylename. This only works because I only have one style of popup menu in my program - I'm not sure what I would do if I wanted two popups to look different!
Hopefully, in later gwt releases, the MenuBar styles will come more closely from the resources passed to the menubar and make less use of dependent style names.
You can simply set a css rule for the that appears in the sub menu like this:
.subMenuIcon > img {
/* override gwt sub menu icon */
width: 6px !important;
height: 11px !important;
background: url('your-image-relative-path.png') no-repeat 0px 0px !important;
}
I'm using zfdatagrid to display a table within a Zend app. How do i fix the width of the table? I can't find any setting in the grid.ini.
public function displaytemptableAction()
{
$config = new Zend_Config_Ini(APPLICATION_PATH.'/grids/grid.ini', 'production');
$db = Zend_Registry::get("db");
$grid = Bvb_Grid::factory('Table',$config,$id='');
$grid->setSource(new Bvb_Grid_Source_Zend_Table(new Model_DbTable_TmpTeamRaceResult()));
//CRUD Configuration
$form = new Bvb_Grid_Form();
$form->setAdd(false)->setEdit(true)->setDelete(true);
$grid->setForm($form);
$grid->setPagination(0);
$grid->setExport(array('xml','pdf'));
$this->view->grid = $grid->deploy();
}
It seems the table width is controlled via a css file in folder './public/styles'
td div input[type='text'] {
width: 98% !important;
border: 1px solid #ddd;
}
Another nice API with rubbish documentation.
Just style it inside your css file like you would any other element. You can right-click view source on the page generated and see what kind of classes(if any) are given to the table/tr/td`s.