javax.swing.text.ParagraphView.Row#sun.swing.SwingUtilities2源码实例Demo

下面列出了javax.swing.text.ParagraphView.Row#sun.swing.SwingUtilities2 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u_jdk   文件: WindowsGraphicsUtils.java
/**
 * Renders a text String in Windows without the mnemonic.
 * This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
 * the overriden paintText methods of the ButtonUI delegates will call this static method.
 * <p>
 * @param g Graphics context
 * @param b Current button to render
 * @param textRect Bounding rectangle to render the text.
 * @param text String to render
 */
public static void paintText(Graphics g, AbstractButton b,
                                    Rectangle textRect, String text,
                                    int textShiftOffset) {
    FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);

    int mnemIndex = b.getDisplayedMnemonicIndex();
    // W2K Feature: Check to see if the Underscore should be rendered.
    if (WindowsLookAndFeel.isMnemonicHidden() == true) {
        mnemIndex = -1;
    }

    XPStyle xp = XPStyle.getXP();
    if (xp != null && !(b instanceof JMenuItem)) {
        paintXPText(b, g, textRect.x + textShiftOffset,
                    textRect.y + fm.getAscent() + textShiftOffset,
                    text, mnemIndex);
    } else {
        paintClassicText(b, g, textRect.x + textShiftOffset,
                         textRect.y + fm.getAscent() + textShiftOffset,
                         text, mnemIndex);
    }
}
 
源代码2 项目: jdk8u-dev-jdk   文件: Utilities.java
/**
 * Draws the given composed text passed from an input method.
 *
 * @param view View hosting text
 * @param attr the attributes containing the composed text
 * @param g  the graphics context
 * @param x  the X origin
 * @param y  the Y origin
 * @param p0 starting offset in the composed text to be rendered
 * @param p1 ending offset in the composed text to be rendered
 * @return  the new insertion position
 */
static int drawComposedText(View view, AttributeSet attr, Graphics g,
                            int x, int y, int p0, int p1)
                                 throws BadLocationException {
    Graphics2D g2d = (Graphics2D)g;
    AttributedString as = (AttributedString)attr.getAttribute(
        StyleConstants.ComposedTextAttribute);
    as.addAttribute(TextAttribute.FONT, g.getFont());

    if (p0 >= p1)
        return x;

    AttributedCharacterIterator aci = as.getIterator(null, p0, p1);
    return x + (int)SwingUtilities2.drawString(
                         getJComponent(view), g2d,aci,x,y);
}
 
源代码3 项目: hottub   文件: BasicFileChooserUI.java
public void mouseClicked(MouseEvent evt) {
    // Note: we can't depend on evt.getSource() because of backward
    // compatibility
    if (list != null &&
        SwingUtilities.isLeftMouseButton(evt) &&
        (evt.getClickCount()%2 == 0)) {

        int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint());
        if (index >= 0) {
            File f = (File)list.getModel().getElementAt(index);
            try {
                // Strip trailing ".."
                f = ShellFolder.getNormalizedFile(f);
            } catch (IOException ex) {
                // That's ok, we'll use f as is
            }
            if(getFileChooser().isTraversable(f)) {
                list.clearSelection();
                changeDirectory(f);
            } else {
                getFileChooser().approveSelection();
            }
        }
    }
}
 
源代码4 项目: Java8CN   文件: DefaultCaret.java
/**
 * If button 1 is pressed, this is implemented to
 * request focus on the associated text component,
 * and to set the caret position. If the shift key is held down,
 * the caret will be moved, potentially resulting in a selection,
 * otherwise the
 * caret position will be set to the new location.  If the component
 * is not enabled, there will be no request for focus.
 *
 * @param e the mouse event
 * @see MouseListener#mousePressed
 */
public void mousePressed(MouseEvent e) {
    int nclicks = SwingUtilities2.getAdjustedClickCount(getComponent(), e);

    if (SwingUtilities.isLeftMouseButton(e)) {
        if (e.isConsumed()) {
            shouldHandleRelease = true;
        } else {
            shouldHandleRelease = false;
            adjustCaretAndFocus(e);
            if (nclicks == 2
                && SwingUtilities2.canEventAccessSystemClipboard(e)) {
                selectWord(e);
            }
        }
    }
}
 
源代码5 项目: jdk8u-dev-jdk   文件: AquaTabbedPaneUI.java
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        // sja fix getTheme().setThemeTextColor(g, isSelected, isPressed && tracking, tabPane.isEnabledAt(tabIndex));
        if (tabPane.isEnabledAt(tabIndex)) {
            g2d.setColor(Color.black);
        } else {
            g2d.setColor(Color.gray);
        }
    } else {
        g2d.setColor(color);
    }

    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
源代码6 项目: jdk8u-jdk   文件: AquaTabbedPaneContrastUI.java
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        g2d.setColor(getNonSelectedTabTitleColor());
        if (tabPane.getSelectedIndex() == tabIndex) {
            boolean pressed = isPressedAt(tabIndex);
            boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
            Color textColor = getSelectedTabTitleColor(enabled, pressed);
            Color shadowColor = getSelectedTabTitleShadowColor(enabled);
            AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
            return;
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
源代码7 项目: dragonwell8_jdk   文件: BasicTabbedPaneUI.java
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
    Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
    int width = tabInsets.left + tabInsets.right + 3;
    Component tabComponent = tabPane.getTabComponentAt(tabIndex);
    if (tabComponent != null) {
        width += tabComponent.getPreferredSize().width;
    } else {
        Icon icon = getIconForTab(tabIndex);
        if (icon != null) {
            width += icon.getIconWidth() + textIconGap;
        }
        View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            width += (int) v.getPreferredSpan(View.X_AXIS);
        } else {
            // plain text
            String title = tabPane.getTitleAt(tabIndex);
            width += SwingUtilities2.stringWidth(tabPane, metrics, title);
        }
    }
    return width;
}
 
源代码8 项目: jdk8u-dev-jdk   文件: DefaultCaret.java
/**
 * If button 1 is pressed, this is implemented to
 * request focus on the associated text component,
 * and to set the caret position. If the shift key is held down,
 * the caret will be moved, potentially resulting in a selection,
 * otherwise the
 * caret position will be set to the new location.  If the component
 * is not enabled, there will be no request for focus.
 *
 * @param e the mouse event
 * @see MouseListener#mousePressed
 */
public void mousePressed(MouseEvent e) {
    int nclicks = SwingUtilities2.getAdjustedClickCount(getComponent(), e);

    if (SwingUtilities.isLeftMouseButton(e)) {
        if (e.isConsumed()) {
            shouldHandleRelease = true;
        } else {
            shouldHandleRelease = false;
            adjustCaretAndFocus(e);
            if (nclicks == 2
                && SwingUtilities2.canEventAccessSystemClipboard(e)) {
                selectWord(e);
            }
        }
    }
}
 
源代码9 项目: openjdk-jdk9   文件: BasicSplitPaneUI.java
private void toggleFocus(JSplitPane splitPane) {
    Component left = splitPane.getLeftComponent();
    Component right = splitPane.getRightComponent();

    KeyboardFocusManager manager =
        KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Component focus = manager.getFocusOwner();
    Component focusOn = getNextSide(splitPane, focus);
    if (focusOn != null) {
        // don't change the focus if the new focused component belongs
        // to the same splitpane and the same side
        if ( focus!=null &&
             ( (SwingUtilities.isDescendingFrom(focus, left) &&
                SwingUtilities.isDescendingFrom(focusOn, left)) ||
               (SwingUtilities.isDescendingFrom(focus, right) &&
                SwingUtilities.isDescendingFrom(focusOn, right)) ) ) {
            return;
        }
        SwingUtilities2.compositeRequestFocus(focusOn);
    }
}
 
源代码10 项目: openjdk-jdk9   文件: AquaTabbedPaneUI.java
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        // sja fix getTheme().setThemeTextColor(g, isSelected, isPressed && tracking, tabPane.isEnabledAt(tabIndex));
        if (tabPane.isEnabledAt(tabIndex)) {
            g2d.setColor(Color.black);
        } else {
            g2d.setColor(Color.gray);
        }
    } else {
        g2d.setColor(color);
    }

    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
源代码11 项目: dragonwell8_jdk   文件: BasicTreeUI.java
/**
 * Invoked when a mouse button has been pressed on a component.
 */
public void mousePressed(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, tree)) {
        return;
    }

    // if we can't stop any ongoing editing, do nothing
    if (isEditing(tree) && tree.getInvokesStopCellEditing()
                        && !stopEditing(tree)) {
        return;
    }

    completeEditing();

    pressedPath = getClosestPathForLocation(tree, e.getX(), e.getY());

    if (tree.getDragEnabled()) {
        mousePressedDND(e);
    } else {
        SwingUtilities2.adjustFocus(tree);
        handleSelection(e);
    }
}
 
源代码12 项目: openjdk-jdk9   文件: DefaultCaret.java
/**
 * If button 1 is pressed, this is implemented to
 * request focus on the associated text component,
 * and to set the caret position. If the shift key is held down,
 * the caret will be moved, potentially resulting in a selection,
 * otherwise the
 * caret position will be set to the new location.  If the component
 * is not enabled, there will be no request for focus.
 *
 * @param e the mouse event
 * @see MouseListener#mousePressed
 */
public void mousePressed(MouseEvent e) {
    int nclicks = SwingUtilities2.getAdjustedClickCount(getComponent(), e);

    if (SwingUtilities.isLeftMouseButton(e)) {
        if (e.isConsumed()) {
            shouldHandleRelease = true;
        } else {
            shouldHandleRelease = false;
            adjustCaretAndFocus(e);
            if (nclicks == 2
                && SwingUtilities2.canEventAccessSystemClipboard(e)) {
                selectWord(e);
            }
        }
    }
}
 
源代码13 项目: openjdk-8   文件: BasicLabelUI.java
private void doRelease(JLabel label) {
    Component labelFor = label.getLabelFor();
    if (labelFor != null && labelFor.isEnabled()) {
        InputMap inputMap = SwingUtilities.getUIInputMap(label, JComponent.WHEN_FOCUSED);
        if (inputMap != null) {
            // inputMap should never be null.
            int dka = label.getDisplayedMnemonic();
            inputMap.remove(KeyStroke.getKeyStroke(dka, BasicLookAndFeel.getFocusAcceleratorKeyMask(), true));
            inputMap.remove(KeyStroke.getKeyStroke(dka, 0, true));
            inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ALT, 0, true));
        }
        if (labelFor instanceof Container &&
                ((Container) labelFor).isFocusCycleRoot()) {
            labelFor.requestFocus();
        } else {
            SwingUtilities2.compositeRequestFocus(labelFor);
        }
    }
}
 
源代码14 项目: Bytecoder   文件: MetalToggleButtonUI.java
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
    int mnemIndex = b.getDisplayedMnemonicIndex();

    /* Draw the Text */
    if(model.isEnabled()) {
        /*** paint the text normally */
        g.setColor(b.getForeground());
    }
    else {
        /*** paint the text disabled ***/
        if (model.isSelected()) {
            g.setColor(c.getBackground());
        } else {
            g.setColor(getDisabledTextColor());
        }
    }
    SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemIndex,
            textRect.x, textRect.y + fm.getAscent());
}
 
源代码15 项目: jdk8u60   文件: DefaultCaret.java
/**
 * If button 1 is pressed, this is implemented to
 * request focus on the associated text component,
 * and to set the caret position. If the shift key is held down,
 * the caret will be moved, potentially resulting in a selection,
 * otherwise the
 * caret position will be set to the new location.  If the component
 * is not enabled, there will be no request for focus.
 *
 * @param e the mouse event
 * @see MouseListener#mousePressed
 */
public void mousePressed(MouseEvent e) {
    int nclicks = SwingUtilities2.getAdjustedClickCount(getComponent(), e);

    if (SwingUtilities.isLeftMouseButton(e)) {
        if (e.isConsumed()) {
            shouldHandleRelease = true;
        } else {
            shouldHandleRelease = false;
            adjustCaretAndFocus(e);
            if (nclicks == 2
                && SwingUtilities2.canEventAccessSystemClipboard(e)) {
                selectWord(e);
            }
        }
    }
}
 
源代码16 项目: JDKSourceCode1.8   文件: WindowsGraphicsUtils.java
/**
 * Renders a text String in Windows without the mnemonic.
 * This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
 * the overriden paintText methods of the ButtonUI delegates will call this static method.
 * <p>
 * @param g Graphics context
 * @param b Current button to render
 * @param textRect Bounding rectangle to render the text.
 * @param text String to render
 */
public static void paintText(Graphics g, AbstractButton b,
                                    Rectangle textRect, String text,
                                    int textShiftOffset) {
    FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);

    int mnemIndex = b.getDisplayedMnemonicIndex();
    // W2K Feature: Check to see if the Underscore should be rendered.
    if (WindowsLookAndFeel.isMnemonicHidden() == true) {
        mnemIndex = -1;
    }

    XPStyle xp = XPStyle.getXP();
    if (xp != null && !(b instanceof JMenuItem)) {
        paintXPText(b, g, textRect.x + textShiftOffset,
                    textRect.y + fm.getAscent() + textShiftOffset,
                    text, mnemIndex);
    } else {
        paintClassicText(b, g, textRect.x + textShiftOffset,
                         textRect.y + fm.getAscent() + textShiftOffset,
                         text, mnemIndex);
    }
}
 
源代码17 项目: openjdk-jdk8u-backup   文件: MotifFileChooserUI.java
protected JScrollPane createFilesList() {
    fileList = new JList<File>();

    if(getFileChooser().isMultiSelectionEnabled()) {
        fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else {
        fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    fileList.setModel(new MotifFileListModel());
    fileList.getSelectionModel().removeSelectionInterval(0, 0);
    fileList.setCellRenderer(new FileCellRenderer());
    fileList.addListSelectionListener(createListSelectionListener(getFileChooser()));
    fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList));
    fileList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JFileChooser chooser = getFileChooser();
            if (SwingUtilities.isLeftMouseButton(e) && !chooser.isMultiSelectionEnabled()) {
                int index = SwingUtilities2.loc2IndexFileList(fileList, e.getPoint());
                if (index >= 0) {
                    File file = fileList.getModel().getElementAt(index);
                    setFileName(chooser.getName(file));
                }
            }
        }
    });
    align(fileList);
    JScrollPane scrollpane = new JScrollPane(fileList);
    scrollpane.setPreferredSize(prefListSize);
    scrollpane.setMaximumSize(MAX_SIZE);
    align(scrollpane);
    fileList.setInheritsPopupMenu(true);
    scrollpane.setInheritsPopupMenu(true);
    return scrollpane;
}
 
源代码18 项目: TencentKona-8   文件: BasicListUI.java
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
        return;
    }

    if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
        return;
    }

    int row = locationToIndex(list, e.getPoint());
    if (row != -1) {
        // 4835633.  Dragging onto a File should not select it.
        if (isFileList) {
            return;
        }
        Rectangle cellBounds = getCellBounds(list, row, row);
        if (cellBounds != null) {
            list.scrollRectToVisible(cellBounds);
            list.setSelectionInterval(row, row);
        }
    }
}
 
源代码19 项目: openjdk-8   文件: BasicTableUI.java
public void actionPerformed(ActionEvent ae) {
    table.editCellAt(pressedRow, pressedCol, null);
    Component editorComponent = table.getEditorComponent();
    if (editorComponent != null && !editorComponent.hasFocus()) {
        SwingUtilities2.compositeRequestFocus(editorComponent);
    }
    return;
}
 
源代码20 项目: jdk8u-dev-jdk   文件: WindowsTableHeaderUI.java
public void paint(Graphics g) {
    Dimension size = getSize();
    State state = State.NORMAL;
    TableColumn draggedColumn = header.getDraggedColumn();
    if (draggedColumn != null &&
            column == SwingUtilities2.convertColumnIndexToView(
                    header.getColumnModel(), draggedColumn.getModelIndex())) {
        state = State.PRESSED;
    } else if (isSelected || hasFocus || hasRollover) {
        state = State.HOT;
    }
    /* on Vista there are more states for sorted columns */
    if (WindowsLookAndFeel.isOnVista()) {
        SortOrder sortOrder = getColumnSortOrder(header.getTable(), column);
        if (sortOrder != null) {
             switch(sortOrder) {
             case ASCENDING:
                 /* falls through */
             case DESCENDING:
                 switch (state) {
                 case NORMAL:
                     state = State.SORTEDNORMAL;
                     break;
                 case PRESSED:
                     state = State.SORTEDPRESSED;
                     break;
                 case HOT:
                     state = State.SORTEDHOT;
                     break;
                 default:
                     /* do nothing */
                 }
             default :
                 /* do nothing */
             }
        }
    }
    skin.paintSkin(g, 0, 0, size.width-1, size.height-1, state);
    super.paint(g);
}
 
源代码21 项目: jdk8u-jdk   文件: GTKLookAndFeel.java
public void initialize() {
    /*
     * We need to call loadGTK() to ensure that the native GTK
     * libraries are loaded.  It is very unlikely that this call will
     * fail (since we've already verified native GTK support in
     * isSupportedLookAndFeel()), but we can throw an error in the
     * failure situation just in case.
     */
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof UNIXToolkit &&
        !((UNIXToolkit)toolkit).loadGTK())
    {
        throw new InternalError("Unable to load native GTK libraries");
    }

    super.initialize();
    inInitialize = true;
    loadStyles();
    inInitialize = false;

    /*
     * Check if system AA font settings should be used.
     * Sun's JDS (for Linux and Solaris) ships with high quality CJK
     * fonts and specifies via fontconfig that these be rendered in
     * B&W to take advantage of the embedded bitmaps.
     * If is a Sun CJK locale or remote display, indicate by the condition
     * variable that in this case the L&F recommends ignoring desktop
     * settings. On other Unixes (eg Linux) this doesn't apply.
     * REMIND 1: The isSunCJK test is really just a place holder
     * until we can properly query fontconfig and use the properties
     * set for specific fonts.
     * REMIND 2: See comment on isLocalDisplay() definition regarding
     * XRender.
     */
    gtkAAFontSettingsCond = !isSunCJK && SwingUtilities2.isLocalDisplay();
    aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(gtkAAFontSettingsCond);
}
 
源代码22 项目: openjdk-jdk9   文件: RepaintManager.java
private boolean isPixelsCopying(JComponent c, Graphics g) {

            AffineTransform tx = getTransform(g);
            GraphicsConfiguration gc = c.getGraphicsConfiguration();

            if (tx == null || gc == null
                    || !SwingUtilities2.isFloatingPointScale(tx)) {
                return false;
            }

            AffineTransform gcTx = gc.getDefaultTransform();

            return gcTx.getScaleX() == tx.getScaleX()
                    && gcTx.getScaleY() == tx.getScaleY();
        }
 
源代码23 项目: Java8CN   文件: BasicButtonUI.java
public void paint(Graphics g, JComponent c)
{
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    String text = layout(b, SwingUtilities2.getFontMetrics(b, g),
           b.getWidth(), b.getHeight());

    clearTextShiftOffset();

    // perform UI specific press action, e.g. Windows L&F shifts text
    if (model.isArmed() && model.isPressed()) {
        paintButtonPressed(g,b);
    }

    // Paint the Icon
    if(b.getIcon() != null) {
        paintIcon(g,c,iconRect);
    }

    if (text != null && !text.equals("")){
        View v = (View) c.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
            v.paint(g, textRect);
        } else {
            paintText(g, b, textRect, text);
        }
    }

    if (b.isFocusPainted() && b.hasFocus()) {
        // paint UI specific focus
        paintFocus(g,b,viewRect,textRect,iconRect);
    }
}
 
源代码24 项目: openjdk-8-source   文件: WindowsLabelUI.java
protected void paintEnabledText(JLabel l, Graphics g, String s,
                                int textX, int textY) {
    int mnemonicIndex = l.getDisplayedMnemonicIndex();
    // W2K Feature: Check to see if the Underscore should be rendered.
    if (WindowsLookAndFeel.isMnemonicHidden() == true) {
        mnemonicIndex = -1;
    }

    g.setColor(l.getForeground());
    SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex,
                                                 textX, textY);
}
 
源代码25 项目: jdk8u-jdk   文件: BasicLabelUI.java
/**
 * Paint clippedText at textX, textY with background.lighter() and then
 * shifted down and to the right by one pixel with background.darker().
 *
 * @see #paint
 * @see #paintEnabledText
 */
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY)
{
    int accChar = l.getDisplayedMnemonicIndex();
    Color background = l.getBackground();
    g.setColor(background.brighter());
    SwingUtilities2.drawStringUnderlineCharAt(l, g, s, accChar,
                                               textX + 1, textY + 1);
    g.setColor(background.darker());
    SwingUtilities2.drawStringUnderlineCharAt(l, g, s, accChar,
                                               textX, textY);
}
 
源代码26 项目: JDKSourceCode1.8   文件: BasicTableUI.java
public void mousePressed(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.isEditing() && !table.getCellEditor().stopCellEditing()) {
        Component editorComponent = table.getEditorComponent();
        if (editorComponent != null && !editorComponent.hasFocus()) {
            SwingUtilities2.compositeRequestFocus(editorComponent);
        }
        return;
    }

    Point p = e.getPoint();
    pressedRow = table.rowAtPoint(p);
    pressedCol = table.columnAtPoint(p);
    outsidePrefSize = pointOutsidePrefSize(pressedRow, pressedCol, p);

    if (isFileList) {
        shouldStartTimer =
            table.isCellSelected(pressedRow, pressedCol) &&
            !e.isShiftDown() &&
            !BasicGraphicsUtils.isMenuShortcutKeyDown(e) &&
            !outsidePrefSize;
    }

    if (table.getDragEnabled()) {
        mousePressedDND(e);
    } else {
        SwingUtilities2.adjustFocus(table);
        if (!isFileList) {
            setValueIsAdjusting(true);
        }
        adjustSelection(e);
    }
}
 
源代码27 项目: Bytecoder   文件: MetalLabelUI.java
/**
 * Just paint the text gray (Label.disabledForeground) rather than
 * in the labels foreground color.
 *
 * @see #paint
 * @see #paintEnabledText
 */
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY)
{
    int mnemIndex = l.getDisplayedMnemonicIndex();
    g.setColor(UIManager.getColor("Label.disabledForeground"));
    SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex,
                                               textX, textY);
}
 
源代码28 项目: openjdk-8-source   文件: MetalLookAndFeel.java
public void propertyChange(PropertyChangeEvent pce) {
    LookAndFeel laf = get();
    if (laf == null || laf != UIManager.getLookAndFeel()) {
        dispose();
        return;
    }
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    boolean lafCond = SwingUtilities2.isLocalDisplay();
    Object aaTextInfo =
        SwingUtilities2.AATextInfo.getAATextInfo(lafCond);
    defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo);
    updateUI();
}
 
/**
 * <p>Invoked after nodes have been removed from the tree.  Note that
 * if a subtree is removed from the tree, this method may only be
 * invoked once for the root of the removed subtree, not once for
 * each individual set of siblings removed.</p>
 *
 * <p>e.path() returns the former parent of the deleted nodes.</p>
 *
 * <p>e.childIndices() returns the indices the nodes had before they were deleted in ascending order.</p>
 */
public void treeNodesRemoved(TreeModelEvent e) {
    if(e != null) {
        int                  changedIndexs[];
        int                  maxCounter;
        TreePath             parentPath = SwingUtilities2.getTreePath(e, getModel());
        FHTreeStateNode      changedParentNode = getNodeForPath
                                   (parentPath, false, false);

        changedIndexs = e.getChildIndices();
        // PENDING(scott): make sure that changedIndexs are sorted in
        // ascending order.
        if(changedParentNode != null && changedIndexs != null &&
           (maxCounter = changedIndexs.length) > 0) {
            Object[]           children = e.getChildren();
            boolean            isVisible =
                (changedParentNode.isVisible() &&
                 changedParentNode.isExpanded());

            for(int counter = maxCounter - 1; counter >= 0; counter--) {
                changedParentNode.removeChildAtModelIndex
                                 (changedIndexs[counter], isVisible);
            }
            if(isVisible) {
                if(treeSelectionModel != null)
                    treeSelectionModel.resetRowSelection();
                if (treeModel.getChildCount(changedParentNode.
                                            getUserObject()) == 0 &&
                              changedParentNode.isLeaf()) {
                    // Node has become a leaf, collapse it.
                    changedParentNode.collapse(false);
                }
                visibleNodesChanged();
            }
            else if(changedParentNode.isVisible())
                visibleNodesChanged();
        }
    }
}
 
源代码30 项目: jdk8u-jdk   文件: BasicListUI.java
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
        return;
    }

    if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
        return;
    }

    int row = locationToIndex(list, e.getPoint());
    if (row != -1) {
        // 4835633.  Dragging onto a File should not select it.
        if (isFileList) {
            return;
        }
        Rectangle cellBounds = getCellBounds(list, row, row);
        if (cellBounds != null) {
            list.scrollRectToVisible(cellBounds);
            list.setSelectionInterval(row, row);
        }
    }
}