2 * Jexer - Java Text User Interface
4 * License: LGPLv3 or later
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
10 * Copyright (C) 2015 Kevin Lamonte
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
33 import jexer
.bits
.CellAttributes
;
36 * TLabel implements a simple label.
38 public final class TLabel
extends TWidget
{
43 private String label
= "";
50 public String
getLabel() {
57 * @param label new label text
59 public void setLabel(final String label
) {
66 private String colorKey
;
69 * Public constructor, using the default "tlabel" for colorKey.
71 * @param parent parent widget
72 * @param text label on the screen
73 * @param x column relative to parent
74 * @param y row relative to parent
76 public TLabel(final TWidget parent
, final String text
, final int x
,
79 this(parent
, text
, x
, y
, "tlabel");
85 * @param parent parent widget
86 * @param text label on the screen
87 * @param x column relative to parent
88 * @param y row relative to parent
89 * @param colorKey ColorTheme key color to use for foreground text
91 public TLabel(final TWidget parent
, final String text
, final int x
,
92 final int y
, final String colorKey
) {
94 // Set parent and window
95 super(parent
, false, x
, y
, text
.length(), 1);
98 this.colorKey
= colorKey
;
102 * Draw a static label.
104 @Override public void draw() {
106 CellAttributes color
= new CellAttributes();
107 color
.setTo(getTheme().getColor(colorKey
));
108 CellAttributes background
= getWindow().getBackground();
109 color
.setBackColor(background
.getBackColor());
111 getScreen().putStringXY(0, 0, label
, color
);