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 text
= "";
48 private String colorKey
;
51 * Public constructor, using the default "tlabel" for colorKey.
53 * @param parent parent widget
54 * @param text label on the screen
55 * @param x column relative to parent
56 * @param y row relative to parent
58 public TLabel(final TWidget parent
, final String text
, final int x
,
61 this(parent
, text
, x
, y
, "tlabel");
67 * @param parent parent widget
68 * @param text label on the screen
69 * @param x column relative to parent
70 * @param y row relative to parent
71 * @param colorKey ColorTheme key color to use for foreground text
73 public TLabel(final TWidget parent
, final String text
, final int x
,
74 final int y
, final String colorKey
) {
76 // Set parent and window
83 setWidth(text
.length());
84 this.colorKey
= colorKey
;
88 * Draw a static label.
90 @Override public void draw() {
92 CellAttributes color
= new CellAttributes();
93 color
.setTo(getTheme().getColor(colorKey
));
94 CellAttributes background
= getWindow().getBackground();
95 color
.setBackColor(background
.getBackColor());
97 getScreen().putStrXY(0, 0, text
, color
);