01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.util;
19:
20: import java.awt.Color;
21: import java.awt.Font;
22:
23: import javax.swing.JLabel;
24: import javax.swing.JScrollPane;
25: import javax.swing.JTextArea;
26: import javax.swing.border.LineBorder;
27:
28: import de.finix.contelligent.client.modules.preferences.PreferencesModule;
29:
30: public class JTextUtil {
31: private final static Font infoFont;
32:
33: private final static Font titleFont;
34:
35: static {
36: int offset = PreferencesModule.getPreferences().getInt(
37: PreferencesModule.FONTSIZE_OFFSET,
38: PreferencesModule.DEFAULT_FONTSIZE_OFFSET);
39: infoFont = new Font("Lucida Sans", Font.PLAIN, 12 + offset);
40: titleFont = new Font("Lucida Sans", Font.BOLD, 12 + offset);
41: }
42:
43: public static Font getInfoFont() {
44: return infoFont;
45: }
46:
47: public static Font getTitleFont() {
48: return titleFont;
49: }
50:
51: public static JLabel createTitle(String title) {
52: JLabel label = new JLabel(title);
53: label.setFont(titleFont);
54: return label;
55: }
56:
57: public static JTextArea createMessageArea(String message) {
58: JTextArea info = new JTextArea(message);
59: info.setEditable(false);
60: info.setLineWrap(true);
61: info.setWrapStyleWord(true);
62: info.setFont(infoFont);
63: info.setFocusable(false);
64: JScrollPane messageScroller = new JScrollPane(info);
65: messageScroller.setBorder(null);
66: return info;
67: }
68:
69: public static JScrollPane createErrorMessageArea(String message) {
70: JTextArea error = new JTextArea(message);
71: error.setEditable(false);
72: error.setLineWrap(true);
73: error.setWrapStyleWord(true);
74: error.setFont(infoFont);
75: error.setFocusable(false);
76: error.setBorder(new LineBorder(Color.red, 2));
77: error.setForeground(Color.red);
78: JScrollPane messageScroller = new JScrollPane(error);
79: messageScroller.setBorder(null);
80: return messageScroller;
81: }
82: }
|