本文整理汇总了Java中javax.swing.plaf.synth.SynthConstants.FOCUSED属性的典型用法代码示例。如果您正苦于以下问题:Java SynthConstants.FOCUSED属性的具体用法?Java SynthConstants.FOCUSED怎么用?Java SynthConstants.FOCUSED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.plaf.synth.SynthConstants
的用法示例。
在下文中一共展示了SynthConstants.FOCUSED属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintInterior
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 );
}
示例2: validate
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");
}
}
示例3: toString
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();
}
示例4: toString
private static String toString(int state) {
StringBuilder sb = new StringBuilder();
if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
sb.append("Default");
}
if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
if (sb.length() > 0) sb.append("+");
sb.append("Disabled");
}
if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
if (sb.length() > 0) sb.append("+");
sb.append("Enabled");
}
if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
if (sb.length() > 0) sb.append("+");
sb.append("Focused");
}
if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
if (sb.length() > 0) sb.append("+");
sb.append("MouseOver");
}
if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
if (sb.length() > 0) sb.append("+");
sb.append("Pressed");
}
if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
if (sb.length() > 0) sb.append("+");
sb.append("Selected");
}
return sb.toString();
}
示例5: getComponentState
public static int getComponentState(JComponent c) {
if (c.isEnabled()) {
if (c.isFocusOwner()) {
return SynthConstants.ENABLED | SynthConstants.FOCUSED;
}
return SynthConstants.ENABLED;
}
return SynthConstants.DISABLED;
}
示例6: setSelectedUI
/**
* 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;
}
}
}
示例7: updateTabContext
/**
* 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);
}
示例8: paintTabBackground
private static void paintTabBackground (Graphics g, int index, int state,
int x, int y, int w, int h) {
if (dummyTab == null) {
dummyTab = new JTabbedPane();
}
Region region = Region.TABBED_PANE_TAB;
if( !(UIManager.getLookAndFeel() instanceof SynthLookAndFeel) ) {
return; //#215311 - unsupported L&F installed
}
SynthLookAndFeel laf = (SynthLookAndFeel) UIManager.getLookAndFeel();
SynthStyleFactory sf = laf.getStyleFactory();
SynthStyle style = sf.getStyle(dummyTab, region);
SynthContext context =
new SynthContext(dummyTab, region, style,
state == SynthConstants.FOCUSED ? SynthConstants.SELECTED : state);
SynthPainter painter = style.getPainter(context);
long t1, t2;
if (state == SynthConstants.DEFAULT) {
t1 = System.currentTimeMillis();
painter.paintTabbedPaneTabBackground(context, g, x, y, w, h, index);
t2 = System.currentTimeMillis();
if ((t2 - t1) > 200) {
LOG.log(Level.WARNING, "painter.paintTabbedPaneTabBackground1 takes too long"
+ " x=" + x + " y=" + y + " w=" + w + " h=" + h + " index:" + index
+ " Time=" + (t2 - t1));
}
} else {
BufferedImage bufIm = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bufIm.createGraphics();
g2d.setBackground(UIManager.getColor("Panel.background"));
g2d.clearRect(0, 0, w, h);
t1 = System.currentTimeMillis();
painter.paintTabbedPaneTabBackground(context, g2d, 0, 0, w, h, index);
t2 = System.currentTimeMillis();
if ((t2 - t1) > 200) {
LOG.log(Level.WARNING, "painter.paintTabbedPaneTabBackground1 takes too long"
+ " x=0" + " y=0" + " w=" + w + " h=" + h + " index:" + index
+ " Time=" + (t2 - t1));
}
// differentiate active and selected tabs, active tab made brighter,
// selected tab darker
RescaleOp op = state == SynthConstants.FOCUSED
? new RescaleOp(1.08f, 0, null)
: new RescaleOp(0.96f, 0, null);
BufferedImage img = op.filter(bufIm, null);
g.drawImage(img, x, y, null);
}
}
示例9: toString
/**
* DOCUMENT ME!
*
* @param state DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
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();
}