本文整理汇总了Java中javax.swing.ButtonModel.isRollover方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel.isRollover方法的具体用法?Java ButtonModel.isRollover怎么用?Java ButtonModel.isRollover使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ButtonModel
的用法示例。
在下文中一共展示了ButtonModel.isRollover方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Paints the Button
*
* @param g
* The graphics
* @param c
* The component
*/
@Override
public void paint(final Graphics g, final JComponent c) {
// super.paint(g, c);
final AbstractButton button = (AbstractButton) c;
button.setRolloverEnabled(true);
final ButtonModel model = button.getModel();
final Rectangle bounds = button.getBounds();
if (model.isPressed() && model.isArmed()) {
g.translate(1, 1);
super.paint(g, c);
g.translate(-1, -1);
downBorder.paintBorder(c, g, 0, 0, bounds.width, bounds.height);
} else if (button.isRolloverEnabled() && model.isRollover()) {
super.paint(g, c);
upBorder.paintBorder(c, g, 0, 0, bounds.width, bounds.height);
} else {
super.paint(g, c);
}
}
示例2: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintIcon(Graphics2D g,ButtonInfo info) {
AbstractButton button = info.button;
Icon icon = button.getIcon();
ButtonModel model = button.getModel();
if(model.isRollover() && button.getRolloverIcon()!=null)
icon = button.getRolloverIcon();
if(model.isPressed() && button.getPressedIcon()!=null)
icon = button.getPressedIcon();
if(model.isSelected() && button.getSelectedIcon()!=null)
icon = button.getSelectedIcon();
if(model.isRollover() && model.isSelected() && button.getRolloverSelectedIcon()!=null)
icon = button.getRolloverSelectedIcon();
if(isEnabled(button)==false && button.getDisabledIcon()!=null)
icon = button.getDisabledIcon();
if(isEnabled(button)==false && model.isSelected() && button.getDisabledIcon()!=null)
icon = button.getDisabledSelectedIcon();
if(icon!=null) {
g.setComposite(isEnabled(button) ? AlphaComposite.SrcOver : SRC_OVER_TRANSLUCENT);
icon.paintIcon(button, g, info.iconRect.x, info.iconRect.y);
}
}
示例3: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
try {
AbstractButton b = (AbstractButton)c;
ButtonModel bm = b.getModel();
if(bm.isRollover()) {
this.paintButtonRollOver(g, b);
} else {
this.paintButtonNormal(g, b);
}
super.paint(g, c);
} catch (Exception var5) {
;
}
}
示例4: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 305: */ {
/* 306:369 */ AbstractButton b = (AbstractButton)c;
/* 307:370 */ ButtonModel model = b.getModel();
/* 308:372 */ if (!model.isEnabled()) {
/* 309:373 */ return;
/* 310: */ }
/* 311:375 */ if (!(c instanceof JToggleButton))
/* 312: */ {
/* 313:376 */ if ((model.isRollover()) && ((!model.isPressed()) || (model.isArmed()))) {
/* 314:377 */ super.paintBorder(c, g, x, y, w, h);
/* 315: */ }
/* 316:379 */ return;
/* 317: */ }
/* 318:382 */ if (model.isRollover())
/* 319: */ {
/* 320:383 */ if ((model.isPressed()) && (model.isArmed())) {
/* 321:384 */ PlasticXPUtils.drawPressedButtonBorder(g, x, y, w, h);
/* 322: */ } else {
/* 323:386 */ PlasticXPUtils.drawPlainButtonBorder(g, x, y, w, h);
/* 324: */ }
/* 325: */ }
/* 326:388 */ else if (model.isSelected()) {
/* 327:389 */ PlasticXPUtils.drawPressedButtonBorder(g, x, y, w, h);
/* 328: */ }
/* 329: */ }
示例5: configureState
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void configureState(CellContext context) {
ButtonModel model = this.rendererComponent.getButtonModel();
if (model != null && context.getComponent() != null) {
Point p = (Point) context.getComponent().getClientProperty(
RolloverProducer.ROLLOVER_KEY);
if (/* hasFocus || */(p != null && (p.x >= 0)
&& (p.x == context.getColumn()) && (p.y == context.getRow()))) {
if (!model.isRollover())
model.setRollover(true);
} else {
if (model.isRollover())
model.setRollover(false);
}
}
}
示例6: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
/* 585: */ {
/* 586:666 */ AbstractButton b = (AbstractButton)c;
/* 587:667 */ ButtonModel model = b.getModel();
/* 588:669 */ if (!model.isEnabled()) {
/* 589:670 */ return;
/* 590: */ }
/* 591:672 */ if (!(c instanceof JToggleButton))
/* 592: */ {
/* 593:673 */ if ((model.isRollover()) && ((!model.isPressed()) || (model.isArmed()))) {
/* 594:674 */ super.paintBorder(c, g, x, y, w, h);
/* 595: */ }
/* 596:676 */ return;
/* 597: */ }
/* 598:683 */ if (model.isRollover())
/* 599: */ {
/* 600:684 */ if ((model.isPressed()) && (model.isArmed())) {
/* 601:685 */ PlasticUtils.drawPressed3DBorder(g, x, y, w, h);
/* 602: */ } else {
/* 603:687 */ PlasticUtils.drawFlush3DBorder(g, x, y, w, h);
/* 604: */ }
/* 605: */ }
/* 606:689 */ else if (model.isSelected()) {
/* 607:690 */ PlasticUtils.drawDark3DBorder(g, x, y, w, h);
/* 608: */ }
/* 609: */ }
示例7: getIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* Returns the Icon to use in painting the button.
*
* @param b the button.
*
* @return the icon.
*/
protected Icon getIcon(AbstractButton b) {
Icon icon = b.getIcon();
ButtonModel model = b.getModel();
if (!model.isEnabled()) {
icon = getSynthDisabledIcon(b, icon);
} else if (model.isPressed() && model.isArmed()) {
icon = getPressedIcon(b, getSelectedIcon(b, icon));
} else if (b.isRolloverEnabled() && model.isRollover()) {
icon = getRolloverIcon(b, getSelectedIcon(b, icon));
} else if (model.isSelected()) {
icon = getSelectedIcon(b, icon);
} else {
icon = getEnabledIcon(b, icon);
}
if (icon == null) {
return getDefaultIcon(b);
}
return icon;
}
示例8: paintText
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void paintText(Graphics pGraphic, AbstractButton pButton, Rectangle pTextRect, String pText)
{
ButtonModel model = pButton.getModel();
if (model.isRollover())
{
pButton.setForeground(HOVER_COLOR);
pButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
else
{
pButton.setForeground(Color.BLACK);
}
super.paintText(pGraphic, pButton, pTextRect, pText);
}
示例9: paintBackground
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
JMenu menu = (JMenu) menuItem;
ButtonModel buttonmodel = menu.getModel();
int w = menu.getWidth();
int h = menu.getHeight();
Color oldColor = g.getColor();
if (!menu.isContentAreaFilled() || !menu.isOpaque()) {
// do nothing
} else {
if (menu.isTopLevelMenu()) {
if (buttonmodel.isSelected()) {
CachedPainter.drawMenuBackground(menuItem, g, 0, 0, w, h);
} else if (buttonmodel.isRollover() && buttonmodel.isEnabled()) {
g.setColor(Colors.MENUBAR_BACKGROUND_HIGHLIGHT);
g.fillRect(0, 0, w, h);
g.setColor(Colors.MENU_ITEM_BACKGROUND);
g.drawRect(0, 0, w - 1, h - 1);
} else {
if (menuItem.getParent() instanceof JMenuBar) {
((MenuBarUI) ((JMenuBar) menuItem.getParent()).getUI()).update(g, menuItem);
}
}
} else {
if (!menuItem.getModel().isSelected()) {
RapidLookTools.drawMenuItemFading(menuItem, g);
} else {
RapidLookTools.drawMenuItemBackground(g, menuItem);
}
}
}
g.setColor(oldColor);
}
示例10: paintComponent
import javax.swing.ButtonModel; //导入方法依赖的package包/类
protected void paintComponent(Graphics graphics) {
SwingTools.disableClearType(this);
((Graphics2D)graphics).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Graphics2D g = (Graphics2D)graphics.create();
ButtonModel model = this.getModel();
if(model.isEnabled() && (model.isRollover() || model.isSelected())) {
g.setColor(this.colorHover);
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10);
}
g.dispose();
super.paintComponent(graphics);
}
示例11: paintComponent
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int h = getHeight();
int w = getWidth();
int height = getHeight();
ButtonModel model = getModel();
if (model.isRollover()) {
glossyColors = ColorUtils.getInStance().getGlossyColor(
rollOverTheme, height, this);
} else {
glossyColors = ColorUtils.getInStance().getGlossyColor(buttonTheme,
height, this);
}
if (model.isSelected() || model.isPressed()) {
glossyColors = ColorUtils.getInStance().getGlossyColor(
selectedTheme, height, this);
}
glossyBgColor = glossyColors[1];
glossyFgColor = glossyColors[0];
drawShape(g2d, w, h);
g2d.dispose();
super.paintComponent(g);
}
示例12: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
AbstractButton b = (AbstractButton) c;
ButtonModel bm = b.getModel();
if (bm.isRollover()) {
paintButtonRollOver(g, b);
} else {
paintButtonNormal(g, b);
}
super.paint(g, c);
}
示例13: paint
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
try {
AbstractButton b = (AbstractButton) c;
ButtonModel bm = b.getModel();
if (bm.isRollover()) {
paintButtonRollOver(g, b);
} else {
paintButtonNormal(g, b);
}
super.paint(g, c);
} catch (Exception e) {
}
}
示例14: paintBorder
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width,
int height) {
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton)c;
ButtonModel model = b.getModel();
boolean isPressed;
boolean isRollover;
boolean isEnabled;
isPressed = model.isPressed() && model.isArmed();
isRollover = b.isRolloverEnabled() && model.isRollover();
isEnabled = b.isEnabled();
if (!isEnabled) {
paintDisabled(b, g, x, y, width, height);
} else {
if (isPressed) {
paintPressed(b, g, x, y, width, height);
} else if (isRollover) {
paintRollover(b, g, x, y, width, height);
} else {
paintNormal(b, g, x, y, width, height);
}
}
}
}
示例15: paintIcon
import javax.swing.ButtonModel; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y)
{
AbstractButton cb = (AbstractButton) c;
ButtonModel model = cb.getModel();
boolean isPressed = (model.isArmed() && model.isPressed());
boolean isRollver = (model.isRollover() && cb.isRolloverEnabled());
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
drawOval(g2d, x, y, (isRollver || isPressed));
if(model.isSelected())
{
fillOval(g2d, x, y);
}
else if(isRollver && isPressed)
{
drawOvalShadow(g2d, x, y);
}
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}