use of java.awt.LayoutManager in project jdk8u_jdk by JetBrains.
the class NimbusLookAndFeel method resolveToolbarConstraint.
/**
* Package private method which returns either BorderLayout.NORTH,
* BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
* on the location of the toolbar in its parent. The toolbar might be
* in PAGE_START, PAGE_END, CENTER, or some other position, but will be
* resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
* actually IS, with CENTER being NORTH.
*
* This code is used to determine where the border line should be drawn
* by the custom toolbar states, and also used by NimbusIcon to determine
* whether the handle icon needs to be shifted to look correct.
*
* Toollbars are unfortunately odd in the way these things are handled,
* and so this code exists to unify the logic related to toolbars so it can
* be shared among the static files such as NimbusIcon and generated files
* such as the ToolBar state classes.
*/
static Object resolveToolbarConstraint(JToolBar toolbar) {
//NORTH/SOUTH/EAST/WEST.
if (toolbar != null) {
Container parent = toolbar.getParent();
if (parent != null) {
LayoutManager m = parent.getLayout();
if (m instanceof BorderLayout) {
BorderLayout b = (BorderLayout) m;
Object con = b.getConstraints(toolbar);
if (con == SOUTH || con == EAST || con == WEST) {
return con;
}
return NORTH;
}
}
}
return NORTH;
}
Aggregations