All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.fedora.swing.jtable.SortHeaderRenderer Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/*
 * -----------------------------------------------------------------------------
 *
 * 

License and Copyright: The contents of this file are subject to the * Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of * the License at * http://www.fedora-commons.org/licenses.

* *

Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License.

* *

The entire file consists of original code.

*

Copyright © 2008 Fedora Commons, Inc.
*

Copyright © 2002-2007 The Rector and Visitors of the University of * Virginia and Cornell University
* All rights reserved.

* * ----------------------------------------------------------------------------- */ package fedora.swing.jtable; import java.awt.*; import javax.swing.*; import javax.swing.table.*; /** *

* Title: SortHeaderRenderer.java *

*

* Description: *

* * ----------------------------------------------------------------------------- * * Portions created by Claude Duguay are Copyright © Claude Duguay, * originally made available at * http://www.fawcette.com/javapro/2002_08/magazine/columns/visualcomponents/ *

* * ----------------------------------------------------------------------------- * * @author Claude Duguay, [email protected] * @version $Id: SortHeaderRenderer.java 5162 2006-10-25 00:49:06Z eddie $ */ public class SortHeaderRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; public static Icon NONSORTED = new SortArrowIcon(SortArrowIcon.NONE); public static Icon ASCENDING = new SortArrowIcon(SortArrowIcon.ASCENDING); public static Icon DECENDING = new SortArrowIcon(SortArrowIcon.DECENDING); public SortHeaderRenderer() { setHorizontalTextPosition(LEFT); setHorizontalAlignment(CENTER); } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { int index = -1; boolean ascending = true; if (table instanceof JSortTable) { JSortTable sortTable = (JSortTable) table; index = sortTable.getSortedColumnIndex(); ascending = sortTable.isSortedColumnAscending(); } if (table != null) { JTableHeader header = table.getTableHeader(); if (header != null) { setForeground(header.getForeground()); setBackground(header.getBackground()); setFont(header.getFont()); } } Icon icon = ascending ? ASCENDING : DECENDING; setIcon(col == index ? icon : NONSORTED); setText((value == null) ? "" : value.toString()); setBorder(UIManager.getBorder("TableHeader.cellBorder")); return this; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy