Search in sources :

Example 21 with JViewport

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();
    }
}
Also used : JViewport(javax.swing.JViewport)

Example 22 with JViewport

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);
    }
}
Also used : JViewport(javax.swing.JViewport) Rectangle(java.awt.Rectangle)

Example 23 with JViewport

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();
}
Also used : JViewport(javax.swing.JViewport) Rectangle(java.awt.Rectangle) Point(java.awt.Point)

Example 24 with JViewport

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);
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) Container(java.awt.Container) JViewport(javax.swing.JViewport)

Example 25 with JViewport

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);
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) Container(java.awt.Container) JViewport(javax.swing.JViewport)

Aggregations

JViewport (javax.swing.JViewport)33 JScrollPane (javax.swing.JScrollPane)12 Component (java.awt.Component)9 Container (java.awt.Container)8 Dimension (java.awt.Dimension)7 Point (java.awt.Point)5 Rectangle (java.awt.Rectangle)5 RTextScrollPane (org.fife.ui.rtextarea.RTextScrollPane)3 Graphics (java.awt.Graphics)2 BufferedImage (java.awt.image.BufferedImage)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JColorChooser (javax.swing.JColorChooser)2 JComponent (javax.swing.JComponent)2 JDesktopPane (javax.swing.JDesktopPane)2 JScrollBar (javax.swing.JScrollBar)2 JTabbedPane (javax.swing.JTabbedPane)2 JTable (javax.swing.JTable)2 ChangeListener (javax.swing.event.ChangeListener)2