1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.setup.PanelHelper;
25 
26 import java.awt.Color;
27 import java.awt.ComponentOrientation;
28 import java.awt.Font;
29 import javax.swing.JTextArea;
30 import javax.swing.UIManager;
31 import org.openoffice.setup.InstallData;
32 
33 public class PanelLabel extends JTextArea {
34 
35     static private Color BackgroundColor;
36     static private Color TextColor;
37     static private Font  TextFont;
38 
PanelLabel()39     public PanelLabel() {
40     }
41 
PanelLabel(String text, int rows, int columns)42     public PanelLabel(String text, int rows, int columns) {
43         super(text, rows, columns);
44         init(true);
45     }
46 
PanelLabel(String text, boolean multiline)47     public PanelLabel(String text, boolean multiline) {
48         super(text);
49         init(multiline);
50     }
51 
PanelLabel(String text)52     public PanelLabel(String text) {
53         super(text);
54         init(false);
55     }
56 
init(boolean multiline)57     private void init(boolean multiline) {
58         setEditable(false);
59         setBackground(BackgroundColor);
60         setForeground(TextColor);
61         setFont(TextFont);
62         setFocusable(false);
63 
64         InstallData data = InstallData.getInstance();
65         if ( data.useRtl() ) { setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
66 
67         if (multiline) {
68             setLineWrap(true);
69             setWrapStyleWord(true);
70         }
71     }
72 
73     static {
74         BackgroundColor = (Color)UIManager.get("Label.background");
75         TextColor       = (Color)UIManager.get("Label.foreground");
76         TextFont        = ((Font)UIManager.get("Label.font")).deriveFont(Font.PLAIN);
77     }
78 }
79