Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,16 @@ else if( c instanceof JToolBar )
appendRow( buf, "Left-to-right", String.valueOf( c.getComponentOrientation().isLeftToRight() ) );
appendRow( buf, "Parent", (c.getParent() != null ? toString( c.getParent().getClass(), classHierarchy ) : "null") );

if( c instanceof JComponent ) {
if( c instanceof JComponent ) {
Object style = ((JComponent)c).getClientProperty( FlatClientProperties.STYLE );
if( style != null )
appendRow( buf, "FlatLaf Style", style.toString() );
}

if( c instanceof FlatInspectorInfoProvider ) {
((FlatInspectorInfoProvider) c).appendInspectorInfo( buf, classHierarchy );
}

// append parent level
buf.append( "<tr><td colspan=\"2\">" );
if( parentLevel > 0 )
Expand All @@ -582,15 +586,15 @@ else if( c instanceof JToolBar )
return buf.toString();
}

private static void appendRow( StringBuilder buf, String key, String value ) {
public static void appendRow( StringBuilder buf, String key, String value ) {
buf.append( "<tr><td valign=\"top\">" )
.append( key )
.append( ":</td><td>" )
.append( value )
.append( "</td></tr>" );
}

private static String toString( Class<?> cls, boolean classHierarchy ) {
public static String toString( Class<?> cls, boolean classHierarchy ) {
StringBuilder buf = new StringBuilder( 100 );
int level = 0;

Expand Down Expand Up @@ -623,15 +627,15 @@ private static String toString( Class<?> cls, boolean classHierarchy ) {
return buf.toString();
}

private static String toString( Insets insets ) {
public static String toString( Insets insets ) {
if( insets == null )
return "null";

return insets.top + ", " + insets.left + ", " + insets.bottom + ", " + insets.right
+ (insets instanceof UIResource ? " UI" : "");
}

private static String toString( Color c ) {
public static String toString( Color c ) {
if( c == null )
return "null";

Expand Down Expand Up @@ -660,15 +664,15 @@ private static String toString( Color c ) {
return buf.toString();
}

private static String toString( Font f ) {
public static String toString( Font f ) {
if( f == null )
return "null";

return f.getFamily() + " " + f.getSize() + " " + f.getStyle()
+ (f instanceof UIResource ? " UI" : "");
}

private static String toString( Border b, boolean classHierarchy ) {
public static String toString( Border b, boolean classHierarchy ) {
if( b == null )
return "null";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2026 FormDev Software GmbH
*
* 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.
*/

package com.formdev.flatlaf.extras;

/**
* Implement this interface in a {@link java.awt.Component} to let {@link FlatInspector}
* show additional, component-specific information in its debug tooltip.
* <p>
* {@link #appendInspectorInfo(StringBuilder,boolean)} is invoked while
* {@code FlatInspector} is building the HTML tooltip content for the inspected component.
* The rows are appended after the built-in "FlatLaf Style" row and before the footer
* that shows the parent inspection level and key bindings hint.
*/
public interface FlatInspectorInfoProvider
{
/**
* Appends additional HTML table rows with component-specific debug information.
* <p>
* Use {@link FlatInspector#appendRow(StringBuilder, String, String)} to append rows,
* and the {@code FlatInspector.toString(...)} helpers (for {@link Class},
* {@link java.awt.Insets}, {@link java.awt.Color}, {@link java.awt.Font},
* {@link javax.swing.border.Border}) to format values the same way the rest of the
* tooltip does, e.g.:
* <pre>
* FlatInspector.appendRow( buf, "Model",
* FlatInspector.toString( model.getClass(), showClassHierarchy ) );
* </pre>
* Values are inserted as-is (not HTML-escaped), so avoid passing raw user text that
* may contain {@code <}, {@code >} or {@code &} unless it is already safe to embed
* as HTML.
*
* @param buf the buffer used to build the tooltip HTML
* @param showClassHierarchy whether the user has toggled display of the full class
* hierarchy (Alt key); pass this through to
* {@code FlatInspector.toString(Class, boolean)} calls for consistency
*/
void appendInspectorInfo( StringBuilder buf, boolean showClassHierarchy );
}