001 package org.fest.swing.query; 002 003 import static org.fest.swing.edt.GuiActionRunner.execute; 004 005 import java.awt.Component; 006 import java.awt.Font; 007 008 import org.fest.swing.annotation.RunsInEDT; 009 import org.fest.swing.edt.GuiQuery; 010 011 /** 012 * Understands an action, executed in the event dispatch thread, that returns the font of a 013 * <code>{@link Component}</code>. 014 * @see Component#getFont() 015 * 016 * @author Alex Ruiz 017 * @author Yvonne Wang 018 */ 019 final public class ComponentFontQuery { 020 021 /** 022 * Returns the font of the given <code>{@link Component}</code>. This action is executed in the event dispatch 023 * thread. 024 * @param component the given <code>Component</code>. 025 * @return the font of the given <code>Component</code>. 026 * @see Component#getFont() 027 */ 028 @RunsInEDT 029 public static Font fontOf(final Component component) { 030 return execute(new GuiQuery<Font>() { 031 protected Font executeInEDT() { 032 return component.getFont(); 033 } 034 }); 035 } 036 037 private ComponentFontQuery() {} 038 }