Java Swing LineBorder isAtScrollPaneRightBorder(Component c, int x)

Here you can find the source of isAtScrollPaneRightBorder(Component c, int x)

Description

is At Scroll Pane Right Border

License

Open Source License

Return

true if the pixel coordinate is just one pixel left of the scrollpanes right border. This can be used to avoid double-border line aliasing effeect where single-lines are needed

Declaration

public static boolean isAtScrollPaneRightBorder(Component c, int x) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://w w  w .  ja  va2 s .c om
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.awt.Component;

import javax.swing.JScrollPane;

import javax.swing.SwingUtilities;

public class Main {
    /**
     * @return true if the pixel coordinate is just one pixel left of the
     *         scrollpanes right border. This can be used to avoid double-border
     *         line aliasing effeect where single-lines are needed
     */
    public static boolean isAtScrollPaneRightBorder(Component c, int x) {
        JScrollPane sp = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, c);
        if (sp != null) {
            int localX = SwingUtilities.convertPoint(c, x, 0, sp).x;
            if (localX + 1 == sp.getWidth()) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. getDefaultLineBorder()
  2. getLineBorder()
  3. getMandatoryBorder()
  4. getToolTipBorder()
  5. intToBorder(int borderConstant)
  6. lineBorder(JComponent comp)
  7. recursiveAddBorderToPanel(JComponent c)
  8. setBorder(JComponent comp)
  9. setBorder(JComponent comp, boolean setBorder)