I want to change height of component by button click, I have two buttons for it ("up" and "down"), and three "positions" of component. FULLSCREEN, when top margin = 0. MIDDLE - when top margin = (display height / 2), and BOTTOM, when top margin = (display height - 100). Starting "position" is BOTTOM
What problem did I met - that when you extend from BOTTOM to MIDDLE - it extends, but then, if you click any of two buttons - graphically nothing changes, but Log prints, that margin of component changes. And it changes correctly. Also Logs from actionListeners are printing everything as it works correctly.
It doesn't changes only graphically.
Why it doesn't change the UI? The component is one of two presented in parent container, which is Layer Layout
Here's actionListeners:
upButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// if component in BOTTOM position - expand to MIDDLE
if (findContainer(f).getStyle().getMargin(
Component.TOP) == display.getDisplayHeight() - 100) {
Log.p("Up action if", Log.ERROR);
setDrawerSize(f, (display.getDisplayHeight() / 2));
// else, expand to FULLSCREEN
} else {
Log.p("Up action else", Log.ERROR);
setDrawerSize(f, display.getDisplayHeight());
}
}
});
downButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// if component in FULLSCREEN position - reduce to MIDDLE
if (findTourMapDrawerContainer(f).getStyle().getMargin(
Component.TOP) == display.getDisplayHeight()) {
Log.p("Down action if", Log.ERROR);
setDrawerSize(f, (display.getDisplayHeight() / 2));
// else, reduce to BOTTOM position
} else {
Log.p("Down action else", Log.ERROR);
setDrawerSize(f, 100);
}
}
});
Here's setDrawerSize() method:
private void setDrawerSize(Form f, int drawerSize) {
Container container = findContainer(f);
container.getStyle().setMargin(Component.TOP, (display.getDisplayHeight() - drawerSize));
container.setScrollableY(false);
if (container.getStyle().getMargin(Component.TOP) < (display.getDisplayHeight() - 100)) {
container.setScrollableY(true);
}
parentContainer.repaint();
}
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: Eclipse
Ubuntu 12.04
Real devices + simulators