Java Code Examples for javax.swing.SwingConstants#NORTH

The following examples show how to use javax.swing.SwingConstants#NORTH . 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
Source File: SeaGlassSplitPaneDivider.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: TriangleIcon.java    From pumpernickel with 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 File: PlafPaintUtils.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
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 4
Source File: UpDownIcon.java    From pumpernickel with 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 5
Source File: FlatSpinnerUI.java    From FlatLaf with 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 6
Source File: CrossBorderLayout.java    From netbeans with 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
Source File: CrossBorderLayout.java    From netbeans with 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 8
Source File: CrossBorderLayout.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isNorth(Integer[] constraints) {
    return constraints[1] == SwingConstants.NORTH;
}
 
Example 9
Source File: DefaultEditorKit.java    From Bytecoder with 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 10
Source File: DefaultEditorKit.java    From openjdk-jdk9 with GNU General Public License v2.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 11
Source File: DefaultEditorKit.java    From jdk8u-jdk with GNU General Public License v2.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 12
Source File: DefaultEditorKit.java    From JDKSourceCode1.8 with 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 13
Source File: DefaultEditorKit.java    From jdk8u60 with GNU General Public License v2.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
Source File: DefaultEditorKit.java    From Java8CN with 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 15
Source File: DefaultEditorKit.java    From dragonwell8_jdk with GNU General Public License v2.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 16
Source File: FlatSplitPaneUI.java    From FlatLaf with 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 17
Source File: ProfilerPopup.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
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 18
Source File: DefaultEditorKit.java    From openjdk-8-source with GNU General Public License v2.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 19
Source File: DefaultEditorKit.java    From jdk8u-jdk with GNU General Public License v2.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 20
Source File: GlassPane.java    From netbeans with 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);
}