Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2013-2014 Erwin Müller <erwin.mueller@deventm.org>
   *
   * This file is part of prefdialog-misc-swing.
   *
   * prefdialog-misc-swing is free software: you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as published by the
   * Free Software Foundation, either version 3 of the License, or (at your
   * option) any later version.
  *
  * prefdialog-misc-swing is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public License
  * along with prefdialog-misc-swing. If not, see <http://www.gnu.org/licenses/>.
  */
 package com.anrisoftware.prefdialog.miscswing.validatingfields;
 
 import java.awt.Color;
 
 
 
Decorated the component depending whether or not the input is valid.

Author(s):
Erwin Mueller, erwin.mueller@deventm.org
Since:
3.0
 
 public class ValidatingComponent {
 
 	private static final AlphaComposite ALPHA = AlphaComposite.getInstance(
 
 	private final JComponent component;
 
 	private final ToolTipShower toolTip;
 
 
 	private boolean valid;

Sets the component.

Parameters:
component the javax.swing.JComponent.
 
 	public ValidatingComponent(JComponent componentToolTipShower toolTip) {
 		this. = component;
 		this. = toolTip;
 		this. = true;
 	}

Sets the invalid background color for the component.

AWT Thread

Should be called on the AWT thread.

Parameters:
color the background java.awt.Color.
 
 	public void setInvalidBackground(Color color) {
 		Color oldValue = this.;
 		this. = color;
 		if (oldValue != color) {
 		}
 	}

Returns the invalid background color for the component.

Returns:
the background java.awt.Color.
 
 	public Color getInvalidBackground() {
 	}

Sets that the input is valid. The component is repaint when the state changed.

AWT Thread

Should be called on the AWT thread.

Parameters:
valid set to true if the current input is valid.
	public void setValid(boolean valid) {
		boolean oldValue = this.;
		this. = valid;
		if (oldValue != valid) {
		}
	}

Returns that the input is valid.

Returns:
true if the current input is valid.
	public boolean isValid() {
		return ;
	}

Sets the invalid text that is shown in a tool-tip if the input is set as not valid.

Parameters:
text the text java.lang.String.
	public void setInvalidText(String text) {
	}

Returns the invalid text that is shown in a tool-tip if the input is set as not valid.

Returns:
the text java.lang.String.
	public String getInvalidText() {
		return .getText();
	}

Paints the overlay for the component.

Parameters:
g the java.awt.Graphics.
	public void paint(Graphics g) {
		if () {
			return;
		}
	}
	private void paintInvalidOverlay(Graphics g) {
		Graphics2D g2 = (Graphics2Dg;
		Rectangle bounds = g.getClipBounds();
		g2.fillRect(bounds.xbounds.ybounds.widthbounds.height);
	}
	public String toString() {
		return new ToStringBuilder(this).toString();
	}
New to GrepCode? Check out our FAQ X