mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
UI inspector: show EmptyBorder insets
This commit is contained in:
@@ -36,6 +36,7 @@ import javax.swing.JToolBar;
|
|||||||
import javax.swing.JToolTip;
|
import javax.swing.JToolTip;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
@@ -186,10 +187,8 @@ public class FlatInspector
|
|||||||
"Class: " + c.getClass().getSimpleName() + " (" + c.getClass().getPackage().getName() + ")\n" +
|
"Class: " + c.getClass().getSimpleName() + " (" + c.getClass().getPackage().getName() + ")\n" +
|
||||||
"Size: " + c.getWidth() + ',' + c.getHeight() + " @ " + c.getX() + ',' + c.getY() + '\n';
|
"Size: " + c.getWidth() + ',' + c.getHeight() + " @ " + c.getX() + ',' + c.getY() + '\n';
|
||||||
|
|
||||||
if( c instanceof Container ) {
|
if( c instanceof Container )
|
||||||
Insets i = ((Container)c).getInsets();
|
text += "Insets: " + toString( ((Container)c).getInsets() ) + '\n';
|
||||||
text += "Insets: " + i.top + ',' + i.left + ',' + i.bottom + ',' + i.right + '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
Insets margin = null;
|
Insets margin = null;
|
||||||
if( c instanceof AbstractButton )
|
if( c instanceof AbstractButton )
|
||||||
@@ -202,7 +201,7 @@ public class FlatInspector
|
|||||||
margin = ((JToolBar) c).getMargin();
|
margin = ((JToolBar) c).getMargin();
|
||||||
|
|
||||||
if( margin != null )
|
if( margin != null )
|
||||||
text += "Margin: " + margin.top + ',' + margin.left + ',' + margin.bottom + ',' + margin.right + '\n';
|
text += "Margin: " + toString( margin ) + '\n';
|
||||||
|
|
||||||
Dimension prefSize = c.getPreferredSize();
|
Dimension prefSize = c.getPreferredSize();
|
||||||
Dimension minSize = c.getMinimumSize();
|
Dimension minSize = c.getMinimumSize();
|
||||||
@@ -211,10 +210,8 @@ public class FlatInspector
|
|||||||
"Min size: " + minSize.width + ',' + minSize.height + '\n' +
|
"Min size: " + minSize.width + ',' + minSize.height + '\n' +
|
||||||
"Max size: " + maxSize.width + ',' + maxSize.height + '\n';
|
"Max size: " + maxSize.width + ',' + maxSize.height + '\n';
|
||||||
|
|
||||||
if( c instanceof JComponent ) {
|
if( c instanceof JComponent )
|
||||||
Border border = ((JComponent)c).getBorder();
|
text += "Border: " + toString( ((JComponent)c).getBorder() ) + '\n';
|
||||||
text += "Border: " + (border != null ? border.getClass().getName() : "null") + '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
text += "Background: " + toString( c.getBackground() ) + '\n' +
|
text += "Background: " + toString( c.getBackground() ) + '\n' +
|
||||||
"Foreground: " + toString( c.getForeground() ) + '\n' +
|
"Foreground: " + toString( c.getForeground() ) + '\n' +
|
||||||
@@ -236,6 +233,13 @@ public class FlatInspector
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String toString( Insets insets ) {
|
||||||
|
if( insets == null )
|
||||||
|
return "null";
|
||||||
|
|
||||||
|
return insets.top + "," + insets.left + ',' + insets.bottom + ',' + insets.right;
|
||||||
|
}
|
||||||
|
|
||||||
private static String toString( Color c ) {
|
private static String toString( Color c ) {
|
||||||
if( c == null )
|
if( c == null )
|
||||||
return "null";
|
return "null";
|
||||||
@@ -253,4 +257,19 @@ public class FlatInspector
|
|||||||
return f.getFamily() + " " + f.getSize() + " " + f.getStyle()
|
return f.getFamily() + " " + f.getSize() + " " + f.getStyle()
|
||||||
+ (f instanceof UIResource ? " UI" : "");
|
+ (f instanceof UIResource ? " UI" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String toString( Border b ) {
|
||||||
|
if( b == null )
|
||||||
|
return "null";
|
||||||
|
|
||||||
|
String s = b.getClass().getName();
|
||||||
|
|
||||||
|
if( b instanceof EmptyBorder )
|
||||||
|
s += '(' + toString( ((EmptyBorder)b).getBorderInsets() ) + ')';
|
||||||
|
|
||||||
|
if( b instanceof UIResource )
|
||||||
|
s += " UI";
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user