Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codenmae one toolbar height

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);
like image 950
Adnane17 Avatar asked Apr 26 '26 07:04

Adnane17


1 Answers

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);
like image 134
Diamond Avatar answered Apr 28 '26 20:04

Diamond



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!