ch.randelshofer.quaqua.QuaquaHighlighter 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!
/*
* @(#)QuaquaHighlighter.java
*
* 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 java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.text.*;
/**
* QuaquaHighlighter.
*
* @author Werner Randelshofer
* @version $Id: QuaquaHighlighter.java 361 2010-11-21 11:19:20Z wrandelshofer $
*/
public class QuaquaHighlighter extends DefaultHighlighter implements UIResource
{
public final static LayeredHighlighter.LayerPainter painterInstance
= new QuaquaHighlightPainter(null);
public static class QuaquaHighlightPainter
extends DefaultHighlighter.DefaultHighlightPainter
{
Color highlightColor;
public QuaquaHighlightPainter(Color color) {
super(color);
}
@Override
public Color getColor() {
return highlightColor == null ? super.getColor() : highlightColor;
}
void setColor(JTextComponent c) {
highlightColor = super.getColor();
if (highlightColor == null) {
highlightColor = c.getSelectionColor();
}
if (! QuaquaUtilities.isFocused(c)) {
highlightColor = UIManager.getColor("TextField.inactiveSelectionBackground");
}
}
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
setColor(c);
super.paint(g, offs0, offs1, bounds, c);
}
public Shape paintLayer(Graphics g, int offs0, int offs1,
Shape bounds, JTextComponent c, View view) {
setColor(c);
return super.paintLayer(g, offs0, offs1, bounds, c,
view);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy