1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * ident "%Z%%M% %I% %E% SMI" 24 * 25 * Copyright (c) 1998-2001 by Sun Microsystems, Inc. 26 * All rights reserved. 27 */ 28 package com.sun.dhcpmgr.ui; 29 30 import javax.swing.JTable; 31 import javax.swing.table.TableCellRenderer; 32 import java.awt.Font; 33 import java.awt.Component; 34 35 /** 36 * This class provides the functionality to indicate to the user which column 37 * a table is currently being sorted on. At present it merely uses a bold 38 * font to display the column name, and does not indicate the collation order. 39 */ 40 public class SortedHeaderRenderer implements TableCellRenderer { 41 TableCellRenderer renderer; 42 43 public SortedHeaderRenderer(JTable table) { 44 renderer = table.getTableHeader().getDefaultRenderer(); 45 } 46 47 public Component getTableCellRendererComponent(JTable table, Object value, 48 boolean isSelected, boolean hasFocus, int row, int column) { 49 Component c = renderer.getTableCellRendererComponent(table, value, 50 isSelected, hasFocus, row, column); 51 Font f = c.getFont(); 52 c.setFont(new Font(f.getName(), Font.BOLD, f.getSize())); 53 return c; 54 } 55 }