mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Made JComboBox, JProgressBar, JSpinner and JXDatePicker non-opaque.
`JPasswordField`, `JScrollPane` and `JTextField` are non-opaque if they have an outside focus border (e.g. IntelliJ and Darcula themes). (issues #20 and #17)
This commit is contained in:
@@ -58,6 +58,7 @@ public class FlatInspector
|
||||
private Component lastComponent;
|
||||
private int lastX;
|
||||
private int lastY;
|
||||
private boolean inspectParent;
|
||||
|
||||
private JComponent highlightFigure;
|
||||
private JToolTip tip;
|
||||
@@ -70,6 +71,7 @@ public class FlatInspector
|
||||
public void mouseMoved( MouseEvent e ) {
|
||||
lastX = e.getX();
|
||||
lastY = e.getY();
|
||||
inspectParent = e.isShiftDown();
|
||||
inspect( lastX, lastY );
|
||||
}
|
||||
} );
|
||||
@@ -105,6 +107,8 @@ public class FlatInspector
|
||||
private void inspect( int x, int y ) {
|
||||
Container contentPane = rootPane.getContentPane();
|
||||
Component c = SwingUtilities.getDeepestComponentAt( contentPane, x, y );
|
||||
if( inspectParent && c != null && c != contentPane )
|
||||
c = c.getParent();
|
||||
if( c == contentPane || (c != null && c.getParent() == contentPane) )
|
||||
c = null;
|
||||
|
||||
@@ -237,7 +241,8 @@ public class FlatInspector
|
||||
}
|
||||
|
||||
text += "Enabled: " + c.isEnabled() + '\n';
|
||||
text += "Opaque: " + c.isOpaque() + '\n';
|
||||
text += "Opaque: " + c.isOpaque() + (c instanceof JComponent &&
|
||||
FlatUIUtils.hasOpaqueBeenExplicitlySet( (JComponent) c ) ? " EXPLICIT" : "") + '\n';
|
||||
text += "Focusable: " + c.isFocusable() + '\n';
|
||||
text += "Left-to-right: " + c.getComponentOrientation().isLeftToRight() + '\n';
|
||||
text += "Parent: " + c.getParent().getClass().getName();
|
||||
|
||||
@@ -307,7 +307,7 @@ public class FlatTestFrame
|
||||
c.setBackground( explicit ? Color.orange : restoreColor );
|
||||
} else {
|
||||
c.setForeground( explicit ? Color.blue : restoreColor );
|
||||
c.setBackground( explicit ? Color.red : restoreColor );
|
||||
c.setBackground( explicit ? Color.green : restoreColor );
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -425,6 +425,14 @@ public class FlatTestFrame
|
||||
contentPanel.getContentPane().remove( content );
|
||||
content = contentFactory.get();
|
||||
contentPanel.getContentPane().add( content );
|
||||
|
||||
if( rightToLeftCheckBox.isSelected() )
|
||||
rightToLeftChanged();
|
||||
if( !enabledCheckBox.isSelected() )
|
||||
enabledChanged();
|
||||
if( explicitColorsCheckBox.isSelected() )
|
||||
explicitColorsChanged();
|
||||
|
||||
contentPanel.revalidate();
|
||||
contentPanel.repaint();
|
||||
}
|
||||
|
||||
@@ -29,15 +29,29 @@ public class FlatTestPanel
|
||||
{
|
||||
@Override
|
||||
protected void paintComponent( Graphics g ) {
|
||||
super.paintComponent( g );
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
|
||||
FlatTestFrame frame = (FlatTestFrame) SwingUtilities.getAncestorOfClass( FlatTestFrame.class, this );
|
||||
if( frame != null && frame.isPaintBackgroundPattern() ) {
|
||||
g.setColor( super.getBackground() );
|
||||
g.fillRect( 0, 0, width, height );
|
||||
|
||||
if( isPaintBackgroundPattern() ) {
|
||||
g.setColor( Color.magenta );
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
for( int y = 0; y < height; y += 2 )
|
||||
g.drawLine( 0, y, width - 1, y );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to see which components paint background with color from parent.
|
||||
*/
|
||||
@Override
|
||||
public Color getBackground() {
|
||||
return isPaintBackgroundPattern() ? Color.red : super.getBackground();
|
||||
}
|
||||
|
||||
private boolean isPaintBackgroundPattern() {
|
||||
FlatTestFrame frame = (FlatTestFrame) SwingUtilities.getAncestorOfClass( FlatTestFrame.class, this );
|
||||
return frame != null && frame.isPaintBackgroundPattern();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user