Here you can find the source of destylize(T comp)
public static <T extends JComponent> T destylize(T comp)
//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; } }