net.alantea.swing.text.StatusLabel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swingplus Show documentation
Show all versions of swingplus Show documentation
Addons over swing package.
The newest version!
package net.alantea.swing.text;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import net.alantea.swing.misc.ResourceManager;
@SuppressWarnings("serial")
public class StatusLabel extends JLabel
{
public enum IconType
{
NONE,
INFORMATION,
WARNING,
ALERT
}
public StatusLabel()
{
setHorizontalAlignment(SwingConstants.LEFT);
setBorder(BorderFactory.createEmptyBorder(2,5,2,0));
}
public void setMessage(String text)
{
setIcon(null);
setText(text);
}
public void setMessage(IconType type, String text)
{
switch(type)
{
case INFORMATION :
setIcon(ResourceManager.getIcon("information.png"));
break;
case WARNING :
setIcon(ResourceManager.getIcon("warning.png"));
break;
case ALERT :
setIcon(ResourceManager.getIcon("alert.png"));
break;
case NONE :
default:
setIcon(null);
break;
}
setText(text);
}
public void setMessage(String iconpath, String text)
{
if (iconpath != null)
{
setIcon(ResourceManager.getIcon(iconpath));
}
setText(text);
}
public void clear()
{
setMessage("");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy