use of javax.swing.JViewport in project JMRI by JMRI.
the class JsonNetworkConnectionConfig method showAdvancedItems.
@Override
protected void showAdvancedItems() {
// we're adding to the normal advanced items.
super.showAdvancedItems();
if (this.adapter.getSystemConnectionMemo() != null && showAdvanced.isSelected()) {
this.cR.gridy += 2;
this.cL.gridy += 2;
this.gbLayout.setConstraints(transmitPrefixLabel, cL);
this.gbLayout.setConstraints(transmitPrefixField, cR);
this._details.add(transmitPrefixLabel);
this._details.add(transmitPrefixField);
this.cR.gridy += 2;
this.cL.gridy += 2;
this.gbLayout.setConstraints(nodeIdentityLabel, cL);
this.gbLayout.setConstraints(nodeIdentityField, cR);
this._details.add(nodeIdentityLabel);
this._details.add(nodeIdentityField);
}
if (this._details.getParent() != null && this._details.getParent() instanceof JViewport) {
JViewport vp = (JViewport) _details.getParent();
vp.revalidate();
vp.repaint();
}
}
use of javax.swing.JViewport in project jabref by JabRef.
the class FieldSetComponent method selectField.
public void selectField(String fieldName) {
int idx = listModel.indexOf(fieldName);
if (idx >= 0) {
list.setSelectedIndex(idx);
}
// Make sure it is visible:
JViewport viewport = sp.getViewport();
Rectangle rectangle = list.getCellBounds(idx, idx);
if (rectangle != null) {
viewport.scrollRectToVisible(rectangle);
}
}
use of javax.swing.JViewport in project jabref by JabRef.
the class MainTable method scrollToCenter.
public void scrollToCenter(int rowIndex, int vColIndex) {
if (!(this.getParent() instanceof JViewport)) {
return;
}
JViewport viewport = (JViewport) this.getParent();
// This rectangle is relative to the table where the
// northwest corner of cell (0,0) is always (0,0).
Rectangle rect = this.getCellRect(rowIndex, vColIndex, true);
// The location of the view relative to the table
Rectangle viewRect = viewport.getViewRect();
// Translate the cell location so that it is relative
// to the view, assuming the northwest corner of the
// view is (0,0).
rect.setLocation(rect.x - viewRect.x, rect.y - viewRect.y);
// Calculate location of rect if it were at the center of view
int centerX = (viewRect.width - rect.width) / 2;
int centerY = (viewRect.height - rect.height) / 2;
// will move the cell to the center
if (rect.x < centerX) {
centerX = -centerX;
}
if (rect.y < centerY) {
centerY = -centerY;
}
rect.translate(centerX, centerY);
// Scroll the area into view.
viewport.scrollRectToVisible(rect);
revalidate();
repaint();
}
use of javax.swing.JViewport in project pcgen by PCGen.
the class JTreeViewTable method unconfigureEnclosingScrollPane.
@Override
protected void unconfigureEnclosingScrollPane() {
super.unconfigureEnclosingScrollPane();
Container p = getParent();
if (p instanceof JViewport) {
Container gp = p.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane) gp;
// Make certain we are the viewPort's view and not, for
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport viewport = scrollPane.getViewport();
if (viewport == null || viewport.getView() != this) {
return;
}
scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, null);
}
}
}
use of javax.swing.JViewport in project pcgen by PCGen.
the class JTreeViewTable method configureEnclosingScrollPane.
@Override
protected void configureEnclosingScrollPane() {
super.configureEnclosingScrollPane();
Container p = getParent();
if (p instanceof JViewport) {
Container gp = p.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane) gp;
// Make certain we are the viewPort's view and not, for
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport viewport = scrollPane.getViewport();
if (viewport == null || viewport.getView() != this) {
return;
}
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, cornerButton);
}
}
}
Aggregations