Reputation: 119
I have a problem in getting the height of my toolbar.
Before adding components the height is "0" and the same result after adding components.
So, is there a way to get the real toolbar height?
btnCnt = new Container();
btnCnt.setUIID(null);
btnCnt.addComponent(btnBack);
btnCnt.addComponent(btnHome);
btnCnt.addComponent(btnExit);
currentForm.setToolBar(homeToolBar);
currentForm.addCommand(SideLogoCommand);
homeToolBar.addCommandToSideMenu(MenuCommand);
homeToolBar.setTitleComponent(btnLogo);
Container commandCnt = new Container(new BorderLayout());
commandCnt.addComponent(BorderLayout.EAST, btnCnt);
commandCnt.setUIID(null);
commandCnt.setPreferredH(homeToolBar.getHeight());
stateMachine.findCntHomeV2Header(currentForm).removeAll();
stateMachine.findCntHomeV2Header(currentForm).repaint();
stateMachine.findCntHomeV2Header(currentForm).addComponent(commandCnt);
Upvotes: 3
Views: 54
Reputation: 7483
What you need is setSameHeight()
not setPrefferedH()
.
setPrefferedH()
is deprecated.
Though if you still want to do it that way, use homeToolBar.getPreferredH()
and not homeToolBar.getHeight()
btnCnt = new Container();
btnCnt.setUIID(null);
btnCnt.addComponent(btnBack);
btnCnt.addComponent(btnHome);
btnCnt.addComponent(btnExit);
currentForm.setToolBar(homeToolBar);
currentForm.addCommand(SideLogoCommand);
homeToolBar.addCommandToSideMenu(MenuCommand);
homeToolBar.setTitleComponent(btnLogo);
Container commandCnt = new Container(new BorderLayout());
commandCnt.addComponent(BorderLayout.EAST, btnCnt);
commandCnt.setUIID(null);
Component.setSameHeight(homeToolBar, commandCnt);
stateMachine.findCntHomeV2Header(currentForm).removeAll();
stateMachine.findCntHomeV2Header(currentForm).repaint();
stateMachine.findCntHomeV2Header(currentForm).addComponent(commandCnt);
Upvotes: 2