Insets ins = ribbonComp.getInsets();
int gap = getLayoutGap();
int availableHeight = ribbonComp.getHeight() - ins.top - ins.bottom;
int availableWidth = ribbonComp.getWidth() - ins.left - ins.right;
HorizontalAlignment horizAlignment = ribbonComp
.getHorizontalAlignment();
JComponent mainComp = ribbonComp.getMainComponent();
Dimension prefMainDim = mainComp.getPreferredSize();
int prefMainWidth = prefMainDim.width;
int finalHeight = Math.min(prefMainDim.height, availableHeight);