net.alantea.swing.text.LabeledLabel 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.JComponent;
import javax.swing.JLabel;
import net.alantea.liteprops.StringProperty;
import net.alantea.swing.layout.percent.PercentConstraints;
import net.alantea.swing.layout.percent.PercentLayout;
import net.alantea.swing.layout.percent.Where;
import net.alantea.utils.MultiMessages;
/**
* The Class LabeledTextField.
*/
public class LabeledLabel extends LabeledText
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The label constraints. */
private PercentConstraints labelConstraints;
/** The field. */
private JLabel content;
/** The label. */
private JLabel label;
private StringProperty data = new StringProperty();
/**
* Instantiates a new labeled text field.
*/
public LabeledLabel()
{
super();
setLayout(new PercentLayout());
label = new JLabel();
labelConstraints = new PercentConstraints(0, 0, 0.25, 1.0);
add(label, labelConstraints);
content = new JLabel();
PercentConstraints fieldConstraints = new PercentConstraints(0, 0, 0, 1.0);
fieldConstraints.setXReferent(label, Where.AFTER);
fieldConstraints.setWReferent(label, Where.AFTER);
add(content, fieldConstraints);
}
public StringProperty getStringProperty()
{
return data;
}
/**
* Sets the label percent.
*
* @param value the new label percent
*/
public void setLabelPercent(double value)
{
labelConstraints.setXPercent(value);
}
/**
* Gets the text.
*
* @return the text
*/
public String getText()
{
return data.get();
}
/**
* Sets the text.
*
* @param value the new text
*/
public void setText(String value)
{
content.setText(value);
}
/**
* Sets the label text.
*
* @param value the new label text
*/
public void setLabelText(String value)
{
label.setText(MultiMessages.get(value));
}
/**
* Gets the label.
*
* @return the label
*/
public JLabel getLabel()
{
return label;
}
/**
* Gets the text field.
*
* @return the text field
*/
@Override
public JComponent getTextField()
{
return content;
}
@Override
public void setEditable(boolean b)
{
// not used
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy