View Javadoc

1   /*
2      Copyright 2002-2006 Martin van den Bemt
3   
4      Licensed under the Apache License, Version 2.0 (the "License");
5      you may not use this file except in compliance with the License.
6      You may obtain a copy of the License at
7   
8          http://www.apache.org/licenses/LICENSE-2.0
9   
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15  */
16  package org.xulux.guilayer.swing.models;
17  
18  import java.awt.Component;
19  
20  import javax.swing.JScrollPane;
21  import javax.swing.JTable;
22  import javax.swing.table.TableCellRenderer;
23  
24  import org.xulux.guilayer.swing.extensions.MultipleLineHeader;
25  import org.xulux.utils.StringUtils;
26  
27  /**
28   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
29   * @version $Id: MultipleLineHeaderRenderer.java,v 1.1 2005/12/18 12:58:21 mvdb Exp $
30   */
31  public class MultipleLineHeaderRenderer implements TableCellRenderer {
32  
33    MultipleLineHeader mlh;
34    JScrollPane scrollPane;
35    
36    public MultipleLineHeaderRenderer(String title) {
37      mlh = new MultipleLineHeader(title);
38  //    scrollPane = new JScrollPane(mlh);
39  //    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
40  //    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
41    }
42    /**
43     * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
44     */
45    public Component getTableCellRendererComponent(JTable table, Object value,
46        boolean isSelected, boolean hasFocus, int row, int column) {
47      mlh.setText(StringUtils.replace((String) value, "\\n", '\n'));
48      return mlh;
49    }
50  
51  }