下面列出了javax.swing.JToolBar#getPreferredSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Returns the largest preferred height or width (depending on orientation)
* of all of the associated toolbars.
*/
private int getPreferredDepth() {
int depth = 0;
final JToolBar[] toolbars = super.getToolBars();
for (final JToolBar toolbar : toolbars) {
final Dimension d = toolbar.getPreferredSize();
if (getOrientation() == ToolBarLayout.HORIZONTAL)
depth = Math.max(depth, d.height);
else
depth = Math.max(depth, d.width);
}
return depth;
}
/**
* Returns the largest preferred height or width (depending on orientation)
* of all of the associated toolbars.
*/
private int getPreferredDepth() {
int depth = 0;
final JToolBar[] toolbars = super.getToolBars();
for (final JToolBar toolbar : toolbars) {
final Dimension d = toolbar.getPreferredSize();
if (getOrientation() == ToolBarLayout.HORIZONTAL)
depth = Math.max(depth, d.height);
else
depth = Math.max(depth, d.width);
}
return depth;
}
/**
* Returns the "length" (width or height) of the provided toolbar depending
* on this boundary's orientation.
*/
protected int getPreferredToolBarLength(final JToolBar toolbar) {
final Dimension d = toolbar.getPreferredSize();
if (ourOrientation == ToolBarLayout.HORIZONTAL)
return d.width;
else
return d.height;
}
/**
* Returns the "depth" (height or width) of the provided toolbar depending
* on this boundary's orientation.
*/
protected int getPreferredToolBarDepth(final JToolBar toolbar) {
final Dimension d = toolbar.getPreferredSize();
if (ourOrientation == ToolBarLayout.HORIZONTAL)
return d.height;
else
return d.width;
}