本文整理匯總了Java中javax.swing.JSplitPane.TOP屬性的典型用法代碼示例。如果您正苦於以下問題:Java JSplitPane.TOP屬性的具體用法?Java JSplitPane.TOP怎麽用?Java JSplitPane.TOP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.swing.JSplitPane
的用法示例。
在下文中一共展示了JSplitPane.TOP屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findFreePosition
private String findFreePosition() {
int leftTop = 0, rightBottom = 0;
int orientation = JSplitPane.HORIZONTAL_SPLIT;
for (int i=0, n=getComponentCount(); i < n; i++) {
LayoutConstraints constraints = getConstraints(i);
if (!(constraints instanceof SplitConstraints))
continue;
int constrPos = convertPosition(constraints);
if (constrPos == 0)
leftTop++;
else if (constrPos == 1)
rightBottom++;
}
if (leftTop == 0 || leftTop < rightBottom)
return orientation == JSplitPane.HORIZONTAL_SPLIT ?
JSplitPane.LEFT : JSplitPane.TOP;
else
return orientation == JSplitPane.HORIZONTAL_SPLIT ?
JSplitPane.RIGHT : JSplitPane.BOTTOM;
}
示例2: readComponentCode
/** This method is used for scanning code structures and recognizing
* components added to containers and their constraints. It's called from
* initialize method. When a relevant code statement is found, then the
* CodeExpression of component is get and added to component, and also the
* layout constraints information is read.
* @param statement CodeStatement to be tested if it contains relevant code
* @param componentCode CodeGroup to be filled with all component code
* @return CodeExpression representing found component; null if the
* statement is not relevant
*/
@Override
protected CodeExpression readComponentCode(CodeStatement statement,
CodeGroup componentCode)
{
CodeExpression[] params = statement.getStatementParameters();
if (params.length != 1)
return null;
String position = null;
Object connectingObject = statement.getMetaObject();
if (getSimpleAddMethod().equals(connectingObject)) {
position = getComponentCount() == 0 ? JSplitPane.LEFT : JSplitPane.RIGHT;
} else if (getSetLeftComponentMethod().equals(connectingObject)) {
position = JSplitPane.LEFT;
} else if (getSetRightComponentMethod().equals(connectingObject)) {
position = JSplitPane.RIGHT;
} else if (getSetTopComponentMethod().equals(connectingObject)) {
position = JSplitPane.TOP;
} else if (getSetBottomComponentMethod().equals(connectingObject)) {
position = JSplitPane.BOTTOM;
}
SplitConstraints constr = new SplitConstraints(position);
getConstraintsList().add(constr);
componentCode.addStatement(statement);
return params[0];
}
示例3: getNewConstraints
/** This method calculates layout constraints for a component dragged
* over a container (or just for mouse cursor being moved over container,
* without any component).
* @param container instance of a real container over/in which the
* component is dragged
* @param containerDelegate effective container delegate of the container
* @param component the real component being dragged, not needed here
* @param index position (index) of the component in its container;
* not needed here
* @param posInCont position of mouse in the container
* @param posInComp position of mouse in the dragged component; not needed
* @return new LayoutConstraints object corresponding to the position of
* the component in the container
*/
@Override
public LayoutConstraints getNewConstraints(Container container,
Container containerDelegate,
Component component,
int index,
Point posInCont,
Point posInComp)
{
if (!(container instanceof JSplitPane))
return null;
JSplitPane splitPane = (JSplitPane) container;
Dimension sz = splitPane.getSize();
int orientation = splitPane.getOrientation();
JButton left = (JButton) splitPane.getClientProperty(LEFT_TOP_BUTTON);
JButton right = (JButton) splitPane.getClientProperty(RIGHT_BOTTOM_BUTTON);
if ( (left == null && right == null) ||
(left != null && right != null) )
{
String freePosition;
if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
if (posInCont.x <= sz.width / 2)
freePosition = JSplitPane.LEFT;
else
freePosition = JSplitPane.RIGHT;
}
else {
if (posInCont.y <= sz.height / 2)
freePosition = JSplitPane.TOP;
else
freePosition = JSplitPane.BOTTOM;
}
assistantParams = freePosition;
return new SplitConstraints(freePosition);
}
assistantParams = findFreePosition();
return new SplitConstraints(assistantParams);
}