001 package com.softnetConsult.utils.swing; 002 003 import java.awt.Component; 004 import java.awt.Font; 005 006 007 /** 008 * A collection of static utility methods providing various swing utilities. 009 * 010 * <p style="font-size:smaller;">This product includes software developed by the 011 * <strong>SoftNet-Consult Java Utility Library</strong> project and its contributors.<br /> 012 * (<a href="http://java-tools.sourceforge.net" target="_blank">http://java-tools.sourceforge.net</a>)<br /> 013 * Copyright (c) 2007-2008 SoftNet-Consult.<br /> 014 * Copyright (c) 2007-2008 G. Paperin.<br /> 015 * All rights reserved. 016 * </p> 017 * <p style="font-size:smaller;">File: SwingTools.java<br /> 018 * Library API version: {@value com.softnetConsult.utils.APIProperties#apiVersion}<br /> 019 * Java compliance version: {@value com.softnetConsult.utils.APIProperties#javaComplianceVersion} 020 * </p> 021 * <p style="font-size:smaller;">Redistribution and use in source and binary forms, with or 022 * without modification, are permitted provided that the following terms and conditions are met: 023 * </p> 024 * <p style="font-size:smaller;">1. Redistributions of source code must retain the above 025 * acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright 026 * notice, this list of conditions and the following disclaimer.<br /> 027 * 2. Redistributions in binary form must reproduce the above acknowledgement of the 028 * SoftNet-Consult Java Utility Library project, the above copyright notice, this list of 029 * conditions and the following disclaimer in the documentation and/or other materials 030 * provided with the distribution.<br /> 031 * 3. All advertising materials mentioning features or use of this software or any derived 032 * software must display the following acknowledgement:<br /> 033 * <em>This product includes software developed by the SoftNet-Consult Java Utility Library 034 * project and its contributors.</em> 035 * </p> 036 * <p style="font-size:smaller;">THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY 037 * OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 038 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 039 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 040 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 041 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 042 * </p> 043 * @author Greg Paperin (<a href="http://www.paperin.org" target="_blank">http://www.paperin.org</a>) 044 * @version {@value com.softnetConsult.utils.APIProperties#apiVersion} 045 */ 046 public final class SwingTools { 047 048 /** 049 * Prevents instances of this class from being created 050 * as this class contains only static utility methods. 051 */ 052 private SwingTools() {} 053 054 /** 055 * Returns a font which is the came as the font of the component, but with {@code PLAIN} style. 056 * 057 * @param c A component. 058 * @return A font which is the came as the font of the component, but with {@code PLAIN} style. 059 */ 060 public static Font getPlainFont(Component c) { 061 062 if (null == c) 063 return new Font("Dialog", Font.PLAIN, 12); 064 065 Font f = c.getFont(); 066 return new Font(f.getName(), Font.PLAIN, f.getSize()); 067 } 068 069 } // public class SwingTools