Major cleanup of Utils class.
[trakem2.git] / ini / trakem2 / display / DisplayableTitleLabel.java
blob22b6f2024328a80405f851ca834024a63763bdb5
1 /**
3 TrakEM2 plugin for ImageJ(C).
4 Copyright (C) 2005, 2006 Albert Cardona and Rodney Douglas.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.txt )
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 You may contact Albert Cardona at acardona at ini.phys.ethz.ch
20 Institute of Neuroinformatics, University of Zurich / ETH, Switzerland.
21 **/
23 package ini.trakem2.display;
25 import javax.swing.JLabel;
27 /** A class to add a MouseListener to a JLabel
28 * and enable the display of only part of the text when too large
31 public final class DisplayableTitleLabel extends JLabel {
33 private String short_text;
35 public DisplayableTitleLabel(final String text) {
36 makeShortText(text);
37 super.setText(short_text);
40 private final void makeShortText(final String text) {
41 if (text.length() > 23) {
42 short_text = text.substring(0, 7) + "..." + text.substring(text.length()-13);
43 super.setToolTipText(text);
44 } else {
45 short_text = text;
46 super.setToolTipText(null);
50 public void setText(final String text) {
51 if (null != text && text.length() > 0) {
52 makeShortText(text);
53 super.setText(short_text);