Java Swing UIManager destylize(T comp)

Here you can find the source of destylize(T comp)

Description

destylize

License

Apache License

Declaration

public static <T extends JComponent> T destylize(T comp) 

Method Source Code


//package com.java2s;
/*// w  ww .  j  av a2s . c  o m
 * Copyright (C) 2011 Cozycode.net
 * 
 * Licensed under 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.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.awt.Color;

import javax.swing.JComponent;

import javax.swing.UIManager;

public class Main {
    public static <T extends JComponent> T destylize(T comp) {
        // The textUI for the nimbus look and feel doesn't match the panel
        // background color when you set it to null.  Furthermore, if
        // the background color is a ColorUIResource or UIResource
        // it is ignored in favor of whatever nimbus prefers to do.
        //
        // We work around this by obtaining the panel background and
        // foreground colors and using them to make plain colors using
        // the values we want.

        Color c = UIManager.getColor("Panel.background");
        Color background = new Color(c.getRed(), c.getGreen(), c.getBlue());

        c = UIManager.getColor("Panel.foreground");
        Color foreground = new Color(c.getRed(), c.getGreen(), c.getBlue());

        comp.setBackground(background);
        comp.setForeground(foreground);
        comp.setBorder(null);
        return comp;
    }
}

Related

  1. createHorizontalLine()
  2. createMessageLabel(String message)
  3. createTabbedPane(int tabPlacement)
  4. decorateMissingValue(JComponent jComponent, boolean missingValueState)
  5. defaultColumnWidth()
  6. disabledIcon(JComponent parent, Icon icon)
  7. disablePaintSliderValue()
  8. drawVistaBackground(Graphics g, Component b, String prefix)
  9. fixGtkPopupStyle()