本文整理汇总了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);
}