Java Swing UIManager initComponentHeight(final Component... components)

Here you can find the source of initComponentHeight(final Component... components)

Description

init Component Height

License

LGPL

Declaration

public static void initComponentHeight(final Component... components) 

Method Source Code


//package com.java2s;
import java.awt.Component;
import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JComboBox;

import javax.swing.JTextField;

import javax.swing.UIManager;

import javax.swing.plaf.metal.MetalLookAndFeel;

public class Main {
    static final String LAF_METAL = MetalLookAndFeel.class.getName();

    public static void initComponentHeight(final Component... components) {
        if (components == null) {
            return;
        }/*from   w  ww. j a v a 2 s .c om*/
        for (final Component component : components) {
            if ((component instanceof JComboBox) || (component instanceof JButton)) {
                component.setPreferredSize(new Dimension(component.getPreferredSize().width, 22));
            } else if (component instanceof JTextField) {
                final String lf = UIManager.getLookAndFeel().getClass().getName();
                int i = 22;
                if (lf.equals(LAF_METAL)) {
                    i = 23;
                }
                component.setPreferredSize(new Dimension(component.getPreferredSize().width, i));
            }
        }
    }
}

Related

  1. getUnfocusedSelectionForeground()
  2. getUnfocusedSelectionForeground()
  3. getWindowsVisualStyle()
  4. GUI_unit(double p_GUI_unit, java.awt.Component c)
  5. init()
  6. initGui()
  7. initialize()
  8. initLnF()
  9. initNimbusStyle()