Typography: Extras: add labelType property to FlatLabel

This commit is contained in:
Karl Tauber
2021-10-13 13:48:03 +02:00
parent e60e3b9fae
commit d8a0a015e4

View File

@@ -16,6 +16,7 @@
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.STYLE_CLASS;
import javax.swing.JLabel;
/**
@@ -26,6 +27,24 @@ import javax.swing.JLabel;
*/
public class FlatLabel
extends JLabel
implements FlatStyleableComponent
implements FlatComponentExtension, FlatStyleableComponent
{
// NOTE: enum names must be equal to typography/font styles
public enum LabelType { h00, h0, h1, h2, h3, h4, large, regular, medium, small, mini, monospaced }
/**
* Returns type of the label.
*/
public LabelType getLabelType() {
return getClientPropertyEnumString( STYLE_CLASS, LabelType.class, null, LabelType.regular );
}
/**
* Specifies type of the label.
*/
public void setLabelType( LabelType labelType ) {
if( labelType == LabelType.regular )
labelType = null;
putClientPropertyEnumString( STYLE_CLASS, labelType );
}
}