Java Utililty Methods JLabel

List of utility methods to do JLabel

Description

The list of methods to do JLabel are organized into topic(s).

Method

BufferedImagegetStroke(final JLabel _jlbl_stroke)
Apply stroke on background.
final int strokeDistance = 10;
if (_jlbl_stroke.getWidth() > 0 && _jlbl_stroke.getHeight() > 0
) {
    BufferedImage bi_stroke = new BufferedImage(_jlbl_stroke.getWidth(), _jlbl_stroke.getHeight(),
            BufferedImage.TYPE_INT_ARGB);
    for (int x = 0; x < bi_stroke.getWidth(); x++) {
        for (int y = 0; y < bi_stroke.getHeight(); y++) {
            try {
...
intgetTimeWidth(JLabel label)
get Time Width
if (dateWidth == -1) {
    try {
        DateFormat dfi = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.US);
        String t = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                .format(dfi.parse("22 Dec 2008 11:22:22"));
        final JLabel jLabel = new JLabel(t);
        jLabel.setFont(label.getFont());
        dateWidth = jLabel.getPreferredSize().width;
...
voidhighlightLabel(JLabel label)
Highlight label (both color and size)
label.setFont(boldFont);
label.setForeground(highlightColor);
BoxleftAlignJLabel(JLabel label)
left Align J Label
Box box = Box.createHorizontalBox();
box.add(label);
box.add(Box.createHorizontalGlue());
return box;
intparseIntFromLabel(JLabel jLabel)
parse Int From Label
return parseIntFromLabel(jLabel, 0);
voidsetBoundsForJLabel(JLabel label, int xOffset, int yOffset)
set Bounds For J Label
setBoundsForComponent(label, label.getText(), xOffset, yOffset);
voidsetErrorBackground(JLabel comp)
set Error Background
comp.setBackground(ERROR_BACKGROUND);
voidsetMnemonic(JLabel label, JComponent message, char mnemonic)
set Mnemonic
label.setDisplayedMnemonic(mnemonic);
label.setLabelFor(message);
voidsetModelValue(JLabel lbl, String value)
set Model Value
if (value != null) {
    lbl.setText(value);
voidsetNSLabel(JLabel nsLabel, String str)
set NS Label
nsLabel.setText(str);
nsLabel.setToolTipText(str);