Java Swing UIManager getDefaultFieldHeigth()

Here you can find the source of getDefaultFieldHeigth()

Description

get Default Field Heigth

License

Open Source License

Declaration

public static int getDefaultFieldHeigth() 

Method Source Code

//package com.java2s;
/*/*from  ww  w. j a va 2  s. c  o m*/
 *    Copyright (C) 2008-2010 Igor Kriznar
 *    
 *    This file is part of GTD-Free.
 *    
 *    GTD-Free is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    
 *    GTD-Free is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    
 *    You should have received a copy of the GNU General Public License
 *    along with GTD-Free.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.swing.JTextField;
import javax.swing.UIManager;

public class Main {
    private static int defaultFieldHeigth;

    public static int getDefaultFieldHeigth() {
        if (defaultFieldHeigth <= 0) {
            JTextField jtf = new JTextField();
            jtf.setText("1234567890"); //$NON-NLS-1$
            defaultFieldHeigth = jtf.getPreferredSize().height;
            if (UIManager.getLookAndFeel() != null && UIManager.getLookAndFeel().getClass().getName()
                    .equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) { //$NON-NLS-1$
                defaultFieldHeigth -= 4;
            }
            if (defaultFieldHeigth < 21) {
                defaultFieldHeigth = 21;
            }
        }

        return defaultFieldHeigth;
    }
}

Related

  1. getClassLoaderForResources()
  2. getClassLoaderForResources()
  3. getDark()
  4. getDefaultActiveBackgroundColour()
  5. getDefaultAttributeSet()
  6. getDefaultForeground()
  7. getDefaultInactiveBackgroundColour()
  8. getErrorIcon()
  9. getGrayFilter()