ch.randelshofer.quaqua.QuaquaToolBarButtonStateBorder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Quaqua Show documentation
Show all versions of Quaqua Show documentation
A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library)
Quaqua Look and Feel (C) 2003-2010, Werner Randelshofer.
Mavenisation by Matt Gumbley, DevZendo.org - for problems with
Mavenisation, see Matt; for issues with Quaqua, see the Quaqua home page.
For full license details, see http://randelshofer.ch/quaqua/license.html
The newest version!
/*
* @(#)ToolbarButtonStateBorder.java 1.1 2005-11-30
*
* Copyright (c) 2004-2010 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with Werner Randelshofer.
* For details see accompanying license terms.
*/
package ch.randelshofer.quaqua;
import ch.randelshofer.quaqua.border.ButtonStateBorder;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.border.*;
/**
* ToolbarButtonStateBorder.
*
* @author Werner Randelshofer
* @version 1.1 2005-11-30 Constructor with tiled image added.
*
1.0 29 March 2005 Created.
*/
public class QuaquaToolBarButtonStateBorder extends ButtonStateBorder {
private boolean isRollover;
public QuaquaToolBarButtonStateBorder(Border e, Border ep, Border es, Border eps, Border d, Border ds, Border i, Border is, Border di, Border dis, boolean isRollover) {
super(e,ep,es,eps,d,ds,i,is,di,dis);
}
/**
* Creates a new instance.
* All borders must have the same insets.
*/
public QuaquaToolBarButtonStateBorder(Border[] borders, boolean isRollover) {
super(borders);
this.isRollover = isRollover;
}
/**
* Creates a new instance.
* All icons must have the same dimensions.
*/
public QuaquaToolBarButtonStateBorder(Image[] images, Insets borderInsets, Insets imageInsets, boolean fill, boolean isRollover) {
super(images, borderInsets, imageInsets, fill);
this.isRollover = isRollover;
}
/**
* Creates a new instance.
* All borders must have the same dimensions.
*/
public QuaquaToolBarButtonStateBorder(Image tiledImage, int tileCount, boolean isTiledHorizontaly,
Insets imageInsets, Insets borderInsets, boolean fill, boolean isRollover) {
super(tiledImage, tileCount, isTiledHorizontaly, imageInsets, borderInsets, fill);
this.isRollover = isRollover;
}
public void paintBorder(Component c, Graphics gr, int x, int y, int width, int height) {
boolean paint = false;
if (c instanceof AbstractButton) {
ButtonModel model = ((AbstractButton) c).getModel();
if (isRollover) {
paint = model.isRollover() || model.isSelected();
} else {
paint = model.isSelected();
}
}
if (paint) {
super.paintBorder(c, gr, x, y, width, height);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy