Here you can find the source of getGtkStyle(Object styleFactory, JComponent component, String regionName)
Parameter | Description |
---|---|
styleFactory | The GTK style factory. |
component | The target component of the style. |
regionName | The name of the target region of the style. |
Parameter | Description |
---|---|
Exception | When reflection fails. |
private static Object getGtkStyle(Object styleFactory, JComponent component, String regionName) throws Exception
//package com.java2s; /*/*from ww w. j av a 2 s . c o m*/ * Copyright (C) 2010-2012 Klaus Reimer <k@ailis.de> * See LICENSE.TXT for licensing information. */ import java.lang.reflect.Field; import java.lang.reflect.Method; import javax.swing.JComponent; public class Main { /** * Called internally by installGtkPopupBugWorkaround. Returns a specific * GTK style object. * * @param styleFactory * The GTK style factory. * @param component * The target component of the style. * @param regionName * The name of the target region of the style. * @return The GTK style. * @throws Exception * When reflection fails. */ private static Object getGtkStyle(Object styleFactory, JComponent component, String regionName) throws Exception { // Create the region object Class<?> regionClass = Class.forName("javax.swing.plaf.synth.Region"); Field field = regionClass.getField(regionName); Object region = field.get(regionClass); // Get and return the style Class<?> styleFactoryClass = styleFactory.getClass(); Method method = styleFactoryClass.getMethod("getStyle", new Class<?>[] { JComponent.class, regionClass }); boolean accessible = method.isAccessible(); method.setAccessible(true); Object style = method.invoke(styleFactory, component, region); method.setAccessible(accessible); return style; } }