Codenmae одна высота панели инструментов

У меня проблема с получением высоты моей панели инструментов.

Перед добавлением компонентов высота равна "0" и такой же результат после добавления компонентов.

Итак, есть ли способ получить реальную высоту панели инструментов?

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);

person Adnane17    schedule 10.01.2016    source источник


Ответы (1)


Вам нужно setSameHeight(), а не setPrefferedH().

setPrefferedH() устарел.

Хотя, если вы все еще хотите сделать это таким образом, используйте homeToolBar.getPreferredH(), а не 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);
person Diamond    schedule 10.01.2016