javax.swing.plaf.synth.SynthConstants Java Examples

The following examples show how to use javax.swing.plaf.synth.SynthConstants. 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: bug7143614.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #2
Source File: bug7143614.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #3
Source File: bug7143614.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #4
Source File: bug7143614.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #5
Source File: bug7143614.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #6
Source File: bug7143614.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #7
Source File: GtkEditorTabCellRenderer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void paintInterior(Graphics g, Component c) {
    GtkEditorTabCellRenderer ren = (GtkEditorTabCellRenderer) c;
    Polygon p = getInteriorPolygon(c);
    int state = ren.isSelected() ? ren.isActive() ? SynthConstants.FOCUSED 
            : SynthConstants.SELECTED : SynthConstants.DEFAULT;
    Rectangle bounds = p.getBounds();
    int yDiff = getHeightDifference(ren);
    paintTabBackground(g, 0, state, bounds.x, bounds.y + yDiff, 
            bounds.width, bounds.height - yDiff);
    
    if (!supportsCloseButton((JComponent)c)) {
        return;
    }
    
    paintCloseButton( g, (JComponent)c );
}
 
Example #8
Source File: bug7143614.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #9
Source File: SeaGlassTreeUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row,
    boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
    // modify the paintContext's state to match the state for the row
    // this is a hack in that it requires knowledge of the subsequent
    // method calls. The point is, the context used in drawCentered
    // should reflect the state of the row, not of the tree.
    boolean isSelected = tree.getSelectionModel().isPathSelected(path);
    int state = paintContext.getComponentState();
    if (isSelected) {
        paintContext.setComponentState(state | SynthConstants.SELECTED);
    }
    super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    paintContext.setComponentState(state);
}
 
Example #10
Source File: bug7143614.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #11
Source File: bug7143614.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #12
Source File: bug7143614.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #13
Source File: bug7143614.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #14
Source File: bug7143614.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #15
Source File: bug7143614.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void validate() throws Exception {
    Method getSelectedUIMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUI");

    getSelectedUIMethod.setAccessible(true);

    Method getSelectedUIStateMethod = SynthLookAndFeel.class.getDeclaredMethod("getSelectedUIState");

    getSelectedUIStateMethod.setAccessible(true);

    if (getSelectedUIMethod.invoke(null) != componentUI) {
        throw new RuntimeException("getSelectedUI returns invalid value");
    }
    if (((Integer) getSelectedUIStateMethod.invoke(null)).intValue() !=
            (SynthConstants.SELECTED | SynthConstants.FOCUSED)) {
        throw new RuntimeException("getSelectedUIState returns invalid value");
    }

}
 
Example #16
Source File: State.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #17
Source File: SeaGlassButtonUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * DOCUMENT ME!
 *
 * @param  b           DOCUMENT ME!
 * @param  defaultIcon DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) {
    ButtonModel model = b.getModel();
    Icon        icon;

    if (model.isSelected()) {
        icon = getIcon(b, b.getDisabledSelectedIcon(), defaultIcon, SynthConstants.DISABLED | SynthConstants.SELECTED);
    } else {
        icon = getIcon(b, b.getDisabledIcon(), defaultIcon, SynthConstants.DISABLED);
    }

    return icon;
}
 
Example #18
Source File: State.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #19
Source File: State.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #20
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Used by the renderers. For the most part the renderers are implemented as
 * Labels, which is problematic in so far as they are never selected. To
 * accomodate this SeaGlassLabelUI checks if the current UI matches that of
 * <code>selectedUI</code> (which this methods sets), if it does, then a
 * state as set by this method is set in the field {@code selectedUIState}.
 * This provides a way for labels to have a state other than selected.
 *
 * @param uix      a UI delegate.
 * @param selected is the component selected?
 * @param focused  is the component focused?
 * @param enabled  is the component enabled?
 * @param rollover is the component's rollover state enabled?
 */
public static void setSelectedUI(ComponentUI uix, boolean selected, boolean focused, boolean enabled, boolean rollover) {
    selectedUI      = uix;
    selectedUIState = 0;

    if (selected) {
        selectedUIState = SynthConstants.SELECTED;

        if (focused) {
            selectedUIState |= SynthConstants.FOCUSED;
        }
    } else if (rollover && enabled) {
        selectedUIState |= SynthConstants.MOUSE_OVER | SynthConstants.ENABLED;

        if (focused) {
            selectedUIState |= SynthConstants.FOCUSED;
        }
    } else {

        if (enabled) {
            selectedUIState |= SynthConstants.ENABLED;
            selectedUIState = SynthConstants.FOCUSED;
        } else {
            selectedUIState |= SynthConstants.DISABLED;
        }
    }
}
 
Example #21
Source File: SeaGlassButtonUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * DOCUMENT ME!
 *
 * @param  b           DOCUMENT ME!
 * @param  defaultIcon DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) {
    ButtonModel model = b.getModel();
    Icon        icon;

    if (model.isSelected()) {
        icon = getIcon(b, b.getRolloverSelectedIcon(), defaultIcon, SynthConstants.MOUSE_OVER | SynthConstants.SELECTED);
    } else {
        icon = getIcon(b, b.getRolloverIcon(), defaultIcon, SynthConstants.MOUSE_OVER);
    }

    return icon;
}
 
Example #22
Source File: State.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #23
Source File: SeaGlassLabelUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
private int getComponentState(JComponent c) {
    int state = SeaGlassLookAndFeel.getComponentState(c);
    if (SeaGlassLookAndFeel.selectedUI == this && state == SynthConstants.ENABLED) {
        state = SeaGlassLookAndFeel.selectedUIState | SynthConstants.ENABLED;
    }
    return state;
}
 
Example #24
Source File: SeaGlassTabbedPaneUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Paint the tab area, including the tabs.
 *
 * @param ss            the SynthContext.
 * @param g             the Graphics context.
 * @param tabPlacement  the side the tabs are on.
 * @param selectedIndex the current selected tab index.
 * @param tabAreaBounds the bounds of the tab area.
 */
protected void paintTabArea(SeaGlassContext ss, Graphics g, int tabPlacement, int selectedIndex, Rectangle tabAreaBounds) {
    Rectangle clipRect = g.getClipBounds();

    ss.setComponentState(SynthConstants.ENABLED);

    // Paint the tab area.
    SeaGlassLookAndFeel.updateSubregion(ss, g, tabAreaBounds);
    ss.getPainter().paintTabbedPaneTabAreaBackground(ss, g, tabAreaBounds.x, tabAreaBounds.y, tabAreaBounds.width,
                                                     tabAreaBounds.height, tabPlacement);
    ss.getPainter().paintTabbedPaneTabAreaBorder(ss, g, tabAreaBounds.x, tabAreaBounds.y, tabAreaBounds.width, tabAreaBounds.height,
                                                 tabPlacement);

    iconRect.setBounds(0, 0, 0, 0);
    textRect.setBounds(0, 0, 0, 0);

    if (runCount == 0) {
        return;
    }

    if (scrollBackwardButton.isVisible()) {
        paintScrollButtonBackground(ss, g, scrollBackwardButton);
    }

    if (scrollForwardButton.isVisible()) {
        paintScrollButtonBackground(ss, g, scrollForwardButton);
    }

    for (int i = leadingTabIndex; i <= trailingTabIndex; i++) {
        if (rects[i].intersects(clipRect) && selectedIndex != i) {
            paintTab(tabContext, g, rects, i, iconRect, textRect);
        }
    }

    if (selectedIndex >= 0) {
        if (rects[selectedIndex].intersects(clipRect)) {
            paintTab(tabContext, g, rects, selectedIndex, iconRect, textRect);
        }
    }
}
 
Example #25
Source File: SeaGlassTabbedPaneUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Update the SynthContext for the tab area for a specified tab.
 *
 * @param index       the tab to update for.
 * @param selected    is the tab selected?
 * @param isMouseDown is the mouse down?
 * @param isMouseOver is the mouse over the tab?
 * @param hasFocus    do we have focus?
 */
private void updateTabContext(int index, boolean selected, boolean isMouseDown, boolean isMouseOver, boolean hasFocus) {
    int state = 0;

    if (!tabPane.isEnabled() || !tabPane.isEnabledAt(index)) {
        state |= SynthConstants.DISABLED;

        if (selected) {
            state |= SynthConstants.SELECTED;
        }
    } else if (selected) {
        state |= (SynthConstants.ENABLED | SynthConstants.SELECTED);

        if (isMouseOver && UIManager.getBoolean("TabbedPane.isTabRollover")) {
            state |= SynthConstants.MOUSE_OVER;
        }
    } else if (isMouseOver) {
        state |= (SynthConstants.ENABLED | SynthConstants.MOUSE_OVER);
    } else {
        state =  SeaGlassLookAndFeel.getComponentState(tabPane);
        state &= ~SynthConstants.FOCUSED; // Don't use tabbedpane focus state.
    }

    if (hasFocus && tabPane.hasFocus()) {
        state |= SynthConstants.FOCUSED; // individual tab has focus
    }

    if (isMouseDown) {
        state |= SynthConstants.PRESSED;
    }

    tabContext.setComponentState(state);
}
 
Example #26
Source File: State.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #27
Source File: MSynthPainter.java    From swift-k with Apache License 2.0 5 votes vote down vote up
@Override
public void paintButtonBackground(SynthContext context, Graphics g, int x, int y, int w, int h) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (context.getComponentState() == SynthConstants.PRESSED) {
        g.setColor(ACCENT);
    }
    else {
        g.setColor(SELECTED);
    }
    g.fillRoundRect(x + 1, y + 1, w - 2, h - 2, 5, 5);
}
 
Example #28
Source File: State.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #29
Source File: State.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}
 
Example #30
Source File: State.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static String toString(int state) {
    StringBuffer buffer = new StringBuffer();
    if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
        buffer.append("Default");
    }
    if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Disabled");
    }
    if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Enabled");
    }
    if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Focused");
    }
    if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("MouseOver");
    }
    if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Pressed");
    }
    if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
        if (buffer.length() > 0) buffer.append("+");
        buffer.append("Selected");
    }
    return buffer.toString();
}