com.databasesandlife.util.swing.JAutoVanishingLabel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common Show documentation
Show all versions of java-common Show documentation
Utility classes developed at Adrian Smith Software (A.S.S.)
package com.databasesandlife.util.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* The same as a JLabel but the text disappears after a while. Use the method
* setVanishingText to set the text. After 5 seconds of the method being
* called, the text disappears.
*
* @author This source is copyright Adrian Smith and licensed under the LGPL 3.
* @see Project on GitHub
*/
@SuppressWarnings("serial")
public class JAutoVanishingLabel
extends JLabel {
protected Timer timer =
new Timer(5000, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
setText("");
}
});
public JAutoVanishingLabel() {
super();
setPreferredSize(new Dimension(200, 17));
}
public void setBold() {
setFont(new Font(getFont().getName(), Font.BOLD, getFont().getSize()));
}
public void setVanishingText(String val) {
setText(val);
timer.stop();
timer.setRepeats(false);
timer.start();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy