本文整理了Java中javax.swing.JSplitPane.getTopComponent()
方法的一些代码示例,展示了JSplitPane.getTopComponent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSplitPane.getTopComponent()
方法的具体详情如下:
包路径:javax.swing.JSplitPane
类名称:JSplitPane
方法名:getTopComponent
暂无
代码示例来源:origin: nodebox/nodebox
public void close() {
Container parent = getParent();
if (!(parent instanceof JSplitPane)) return;
JSplitPane split = (JSplitPane) parent;
Component firstComponent = split.getTopComponent();
Component secondComponent = split.getBottomComponent();
Component remainingComponent = firstComponent == this ? secondComponent : firstComponent;
split.setTopComponent(null);
split.setBottomComponent(null);
Container grandParent = parent.getParent();
if (grandParent instanceof JSplitPane) {
JSplitPane grandSplit = (JSplitPane) grandParent;
// Remove the split pane.
if (split == grandSplit.getTopComponent()) {
grandSplit.setTopComponent(remainingComponent);
} else {
grandSplit.setBottomComponent(remainingComponent);
}
} else {
grandParent.remove(parent);
grandParent.add(remainingComponent);
}
grandParent.validate();
}
代码示例来源:origin: nodebox/nodebox
if (parent instanceof JSplitPane) {
JSplitPane parentSplit = (JSplitPane) parent;
boolean first = parentSplit.getTopComponent() == this;
if (first) {
parentSplit.setTopComponent(newPane);
代码示例来源:origin: nodebox/nodebox
private void split(int orientation) {
Container parent = getParent();
if (parent instanceof JSplitPane) {
JSplitPane parentSplit = (JSplitPane) parent;
boolean first = parentSplit.getTopComponent() == this;
if (first) {
parentSplit.setTopComponent(null);
} else {
parentSplit.setBottomComponent(null);
}
CustomSplitPane split = new CustomSplitPane(orientation, this, this.duplicate());
if (first) {
parentSplit.setTopComponent(split);
} else {
parentSplit.setBottomComponent(split);
}
parentSplit.validate();
} else {
parent.remove(this);
CustomSplitPane split = new CustomSplitPane(orientation, this, this.duplicate());
parent.add(split);
parent.validate();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
private Component getFirstComponent(JSplitPane splitPane) {
if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
return splitPane.getLeftComponent();
} else {
return splitPane.getTopComponent();
}
}
代码示例来源:origin: realXuJiang/bigtable-sql
private int getDividerLocation(int wantedBottomComponentHeight, JSplitPane splitPn)
{
int splitBarSize =
splitPn.getSize().height -
splitPn.getBottomComponent().getSize().height -
splitPn.getTopComponent().getSize().height - 1;
int divLoc = splitPn.getSize().height - wantedBottomComponentHeight - splitBarSize;
return divLoc;
}
}
代码示例来源:origin: com.github.tornaia/aott-desktop-client-core
@Override
public void propertyChange(PropertyChangeEvent evt) {
int min = jSplitPane.getMinimumDividerLocation();
int max = jSplitPane.getMaximumDividerLocation();
int previous = lastDividerLocation.get();
int actual = jSplitPane.getDividerLocation();
boolean initial = lastDividerLocation.get() == -1;
boolean attachToTop = actual < (max - min) * 0.15D && previous > actual;
boolean attachToBottom = actual > (max - min) * 0.85D && actual > previous;
boolean detachFromTop = previous == min && actual > previous;
boolean detachFromBottom = previous == max && actual < previous;
if (!initial) {
if (attachToTop) {
jSplitPane.setDividerLocation(min);
jSplitPane.getTopComponent().setVisible(false);
} else if (detachFromTop) {
jSplitPane.setDividerLocation((int) ((max - min) * 0.15D));
jSplitPane.getTopComponent().setVisible(true);
} else if (attachToBottom) {
jSplitPane.setDividerLocation(max);
jSplitPane.getBottomComponent().setVisible(false);
} else if (detachFromBottom) {
jSplitPane.setDividerLocation((int) ((max - min) * 0.85D));
jSplitPane.getBottomComponent().setVisible(true);
}
}
lastDividerLocation.set(actual);
}
}
代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun
@Override
public void componentResized(ComponentEvent e) {
if(getRightPanel().getTopComponent() == null && getRightPanel().getBottomComponent() == null) {
horizontalSplitPane.setDividerLocation(1.0);
}
super.componentResized(e);
}
});
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
private int getDividerLocation(int wantedBottomComponentHeight, JSplitPane splitPn)
{
int splitBarSize =
splitPn.getSize().height -
splitPn.getBottomComponent().getSize().height -
splitPn.getTopComponent().getSize().height - 1;
int divLoc = splitPn.getSize().height - wantedBottomComponentHeight - splitBarSize;
return divLoc;
}
}
代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun
/**
* Repaints the this panel so that the right panel will properly resize.
*/
private void refeshRightPanel() {
this.invalidate();
this.validate();
this.repaint();
if(rightPanel.getTopComponent() == null && rightPanel.getBottomComponent() == null) {
horizontalSplitPane.setDividerLocation(1.0);
}
if (rightPanel.getTopComponent() == null || rightPanel.getBottomComponent() == null) {
rightPanel.setDividerSize(0);
} else {
rightPanel.setDividerSize(2);
rightPanel.setDividerLocation(0.5);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-ui
public static int getPref(JSplitPane jSplitPane) {
if (jSplitPane == null) {
return 0;
}
Component c = jSplitPane.getTopComponent();
if (c == null || c.getPreferredSize() == null) {
if (jSplitPane.getSize() != null) {
return jSplitPane.getSize().height;
} else {
return 0;
}
}
if (JScrollPane.class.isAssignableFrom(c.getClass())) {
JScrollBar jsb = ((JScrollPane) c).getHorizontalScrollBar();
if (jsb.isShowing()) {
return jsb.getSize().height + c.getPreferredSize().height + jSplitPane.getInsets().top;
}
}
return c.getPreferredSize().height + jSplitPane.getInsets().top;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-highlight
@Override
public void hierarchyChanged(HierarchyEvent e) {
if ((HierarchyEvent.SHOWING_CHANGED & e.getChangeFlags()) == HierarchyEvent.SHOWING_CHANGED){
JSplitPane p = (JSplitPane)e.getSource();
if (show) {
int l1 = p.getTopComponent().getHeight();
int l2 = p.getBottomComponent().getHeight();
if (l1 > 0 && l2 > 0) {
NbPreferences.forModule(ErrorIncludeDialog.class).putDouble("verticalDivider", ((double)l1)/(l1+l2)); // NOI18N
}
} else {
p.setDividerLocation(NbPreferences.forModule(ErrorIncludeDialog.class).getDouble("verticalDivider", 0.65)); // NOI18N
show = true;
}
}
}
});
代码示例来源:origin: de.richtercloud/flexdock-core
private static SplitNode createNode(DockingPort port, JSplitPane split) {
int orientation = split.getOrientation();
boolean topLeft = split.getLeftComponent()==port? true: false;
int region = 0;
String siblingId = null;
if(topLeft) {
region = orientation==JSplitPane.VERTICAL_SPLIT? TOP: LEFT;
siblingId = getSiblingId(split.getRightComponent());
} else {
region = orientation==JSplitPane.VERTICAL_SPLIT? BOTTOM: RIGHT;
siblingId = getSiblingId(split.getLeftComponent());
}
int size = orientation==JSplitPane.VERTICAL_SPLIT? split.getHeight(): split.getWidth();
int divLoc = split.getDividerLocation();
int testSize = 0;
if (orientation == JSplitPane.VERTICAL_SPLIT) {
testSize += split.getTopComponent().getHeight() + split.getBottomComponent().getHeight() + split.getDividerSize();
} else {
testSize += split.getLeftComponent().getWidth() + split.getRightComponent().getWidth() + split.getDividerSize();
}
float percentage;
if (split instanceof DockingSplitPane && ((DockingSplitPane) split).getPercent() != -1) {
percentage = (float) ((DockingSplitPane) split).getPercent();
} else {
percentage = divLoc / (float)size;
}
return new SplitNode(orientation, region, percentage, siblingId);
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
case BOTTOM:
add(collapsedPanel, BorderLayout.SOUTH);
add(splitPane.getTopComponent());
break;
default: // RIGHT:
内容来源于网络,如有侵权,请联系作者删除!