Java Code Examples for javax.swing.SwingConstants#NORTH

The following examples show how to use javax.swing.SwingConstants#NORTH . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Creates and return an instance of JButton that can be used to collapse
 * the left/top component in the split pane.
 *
 * @return a one-touch button.
 */
protected JButton createLeftOneTouchButton() {
    SeaGlassArrowButton b            = new SeaGlassArrowButton(SwingConstants.NORTH);
    int                 oneTouchSize = lookupOneTouchSize();

    b.setName("SplitPaneDivider.leftOneTouchButton");
    b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
    b.setCursor(Cursor.getPredefinedCursor(
        splitPane.getOrientation() == 
            JSplitPane.HORIZONTAL_SPLIT ? 
                    Cursor.W_RESIZE_CURSOR:Cursor.N_RESIZE_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    b.setDirection(mapDirection(true));

    return b;
}
 
Example 2
Source Project: pumpernickel   File: TriangleIcon.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a new TriangleIcon.
 * 
 * @param direction
 *            one of the SwingConstant constants for NORTH, SOUTH, EAST or
 *            WEST. For example, if the direction is EAST this triangle will
 *            point to the right.
 * @param width
 *            the width of this icon
 * @param height
 *            the height of this icon
 * @param color
 *            the color to fill this icon with.
 */
public TriangleIcon(int direction, int width, int height, Color color) {
	this.direction = direction;
	this.width = width;
	this.height = height;
	this.color = color;

	if (direction == SwingConstants.EAST
			|| direction == SwingConstants.RIGHT) {
		triangle.moveTo(0, 0);
		triangle.lineTo(width, height / 2);
		triangle.lineTo(0, height);
	} else if (direction == SwingConstants.WEST
			|| direction == SwingConstants.LEFT) {
		triangle.moveTo(width, 0);
		triangle.lineTo(0, height / 2);
		triangle.lineTo(width, height);
	} else if (direction == SwingConstants.NORTH
			|| direction == SwingConstants.TOP) {
		triangle.moveTo(0, height);
		triangle.lineTo(width / 2, 0);
		triangle.lineTo(width, height);
	} else if (direction == SwingConstants.SOUTH
			|| direction == SwingConstants.BOTTOM) {
		triangle.moveTo(0, 0);
		triangle.lineTo(width / 2, height);
		triangle.lineTo(width, 0);
	} else {
		throw new IllegalArgumentException(
				"direction ("
						+ direction
						+ ") must be one of the SwingConstant constants: NORTH, SOUTH, EAST or WEST.");
	}
	triangle.closePath();
}
 
Example 3
Source Project: pumpernickel   File: UpDownIcon.java    License: MIT License 5 votes vote down vote up
public UpDownIcon(int triangleWidth, int triangleHeight, int trianglePadding) {
	downIcon = new TriangleIcon(SwingConstants.SOUTH, triangleWidth,
			triangleHeight);
	upIcon = new TriangleIcon(SwingConstants.NORTH, triangleWidth,
			triangleHeight);
	this.trianglePadding = trianglePadding;
}
 
Example 4
Source Project: FlatLaf   File: FlatSpinnerUI.java    License: Apache License 2.0 5 votes vote down vote up
private Component createArrowButton( int direction, String name ) {
	FlatArrowButton button = new FlatArrowButton( direction, arrowType, buttonArrowColor,
		buttonDisabledArrowColor, buttonHoverArrowColor, null );
	button.setName( name );
	button.setYOffset( (direction == SwingConstants.NORTH) ? 1 : -1 );
	if( direction == SwingConstants.NORTH )
		installNextButtonListeners( button );
	else
		installPreviousButtonListeners( button );
	return button;
}
 
Example 5
Source Project: netbeans   File: CrossBorderLayout.java    License: Apache License 2.0 5 votes vote down vote up
public Component getLayoutComponent(int constraint) {
    if (constraint == SwingConstants.NORTH) return north;
    if (constraint == SwingConstants.WEST) return west;
    if (constraint == SwingConstants.SOUTH) return south;
    if (constraint == SwingConstants.EAST) return east;
    if (constraint == SwingConstants.CENTER) return center;
    throw new IllegalArgumentException("Illegal constraint: " + // NOI18N
            constraintName(constraint));
}
 
Example 6
Source Project: netbeans   File: CrossBorderLayout.java    License: Apache License 2.0 5 votes vote down vote up
private static void checkSupported(int constraint) {
    if (constraint == SwingConstants.NORTH) return;
    if (constraint == SwingConstants.WEST) return;
    if (constraint == SwingConstants.SOUTH) return;
    if (constraint == SwingConstants.EAST) return;
    if (constraint == SwingConstants.NORTH_WEST) return;
    if (constraint == SwingConstants.NORTH_EAST) return;
    if (constraint == SwingConstants.SOUTH_WEST) return;
    if (constraint == SwingConstants.SOUTH_EAST) return;
    if (constraint == SwingConstants.CENTER) return;
    
    throw new IllegalArgumentException("Unsupported constraint: " + constraint); // NOI18N
}
 
Example 7
private static void drawColors(Color[] colors,Graphics g,int x1,int y1,int x2,int y2,int direction) {
	for(int a = 0; a<colors.length; a++) {
		g.setColor(colors[colors.length-a-1]);
		if(direction==SwingConstants.SOUTH) {
			g.drawLine(x1, y1-a, x2, y2-a);
		} else if(direction==SwingConstants.NORTH) {
			g.drawLine(x1, y1+a, x2, y2+a);
		} else if(direction==SwingConstants.EAST) {
			g.drawLine(x1-a, y1, x2-a, y2);
		} else if(direction==SwingConstants.WEST) {
			g.drawLine(x1+a, y1, x2+a, y2);
		}
	}
}
 
Example 8
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 9
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 10
public void show() {
//        Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
//        if (focusOwner != null) focusRef = new WeakReference(focusOwner);
            
        owner = ownerRef == null ? null : ownerRef.get();
        ownerLocation = owner == null ? null : owner.getLocationOnScreen();
        
        window = new JWindow(owner);
        window.setType(Window.Type.POPUP);
        window.setAlwaysOnTop(false);
        window.setFocusable(true);
        window.setFocusableWindowState(true);
        window.setAutoRequestFocus(true);
        
        window.getContentPane().add(content);
        window.pack();
        
        if (popupAlign == -1) {
            window.setLocation(location.getLocation());
        } else {
            Dimension size = content.getSize();
            
            int x;
            switch (popupAlign) {
                case SwingConstants.EAST:
                case SwingConstants.NORTH_EAST:
                case SwingConstants.SOUTH_EAST:
                    x = location.x + location.width - size.width + 1;
                    break;
                default:
                    x = location.x + 1;
                    break;
            }
            
            int y;
            switch (popupAlign) {
                case SwingConstants.NORTH:
                case SwingConstants.NORTH_EAST:
                case SwingConstants.NORTH_WEST:
                    y = location.y - size.height + 1;
                    break;
                default:
                    y = location.y + location.height + 1;
                    break;
            }
            
            window.setLocation(x, y);
        }
        
        window.setVisible(true);
        
        Component defaultFocus = content.getFocusTraversalPolicy().getDefaultComponent(content);
        if (defaultFocus != null) defaultFocus.requestFocusInWindow();
        
        content.installListeners();
        
        if (listener != null) listener.popupShown();
    }
 
Example 11
Source Project: FlatLaf   File: FlatSplitPaneUI.java    License: Apache License 2.0 4 votes vote down vote up
public FlatOneTouchButton( boolean left ) {
	super( SwingConstants.NORTH, arrowType, oneTouchArrowColor, null, oneTouchHoverArrowColor, null );
	setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );

	this.left = left;
}
 
Example 12
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 13
Source Project: Java8CN   File: DefaultEditorKit.java    License: Apache License 2.0 4 votes vote down vote up
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 14
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 15
Source Project: JDKSourceCode1.8   File: DefaultEditorKit.java    License: MIT License 4 votes vote down vote up
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 16
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 17
/** The operation to perform when this action is triggered. */
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 18
Source Project: Bytecoder   File: DefaultEditorKit.java    License: Apache License 2.0 4 votes vote down vote up
/** The operation to perform when this action is triggered. */
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 19
private static boolean isNorth(Integer[] constraints) {
    return constraints[1] == SwingConstants.NORTH;
}
 
Example 20
Source Project: netbeans   File: GlassPane.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Determines if we are moving north side of the component during resizing.
 *
 * @return {@code true} is we are moving north side of the component,
 * returns {@code false} otherwise.
 */
private boolean isResizingNorthward() {
    return (resizingMode == SwingConstants.NORTH
            || resizingMode == SwingConstants.NORTH_EAST
            || resizingMode == SwingConstants.NORTH_WEST);
}