Reputation: 24068
I can set the left side width of a HorizontalSplitPanel
in pixels like below.
splitter.setSplitPosition(40, Sizeable.Unit.PIXELS);
With above, since the split position is 40 pixels, the left side of splitter is 40 pixels in width. There is a certain case where I want to specify the width of right side of the splitter in pixels.
But, I cannot set the right side with in above way because there's no way to find the total width of the splitter. If I could get the total width, I could have done it like below.
splitter.setSplitPosition(splitter.totalWidth() - 40, Sizeable.Unit.PIXELS);
So, is there any way I can define the right side width in pixels?
Upvotes: 1
Views: 189
Reputation: 37008
You can "reverse" the split position. See setSplitPosition(float pos, Sizeable.Unit unit, boolean reverse)
:
reverse
- if set to true the split splitter position is measured by the second region else it is measured by the first region
E.g.:
// run with `spring run vaadin.groovy`
@Grapes([
@Grab('org.vaadin.spring:spring-boot-vaadin:0.0.5.RELEASE'),
@Grab('com.vaadin:vaadin-server:7.5.9'),
@Grab('com.vaadin:vaadin-client-compiled:7.5.9'),
@Grab('com.vaadin:vaadin-themes:7.5.9'),
])
import org.vaadin.spring.annotation.VaadinUI
import com.vaadin.server.VaadinRequest
import com.vaadin.ui.*
import com.vaadin.annotations.*
import com.vaadin.server.Sizeable
@VaadinUI
@Theme("valo")
class MyUI extends UI {
protected void init(VaadinRequest request) {
setContent(new HorizontalSplitPanel(new Label("A"), new Label("B")).with{
setSplitPosition(40, Sizeable.Unit.PIXELS, true /*!*/)
it
})
}
}
Upvotes: 1