mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
Button and ToggleButton: ToolBar buttons now respect explicitly set background color. If no background color is set, then the button background is not painted anymore (issue #191)
This commit is contained in:
@@ -27,6 +27,9 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
- Button and ToggleButton: Threat Unicode surrogate character pair as single
|
- Button and ToggleButton: Threat Unicode surrogate character pair as single
|
||||||
character and make button square. (issue #234)
|
character and make button square. (issue #234)
|
||||||
|
- Button and ToggleButton: ToolBar buttons now respect explicitly set background
|
||||||
|
color. If no background color is set, then the button background is not
|
||||||
|
painted anymore. (issue #191)
|
||||||
- TabbedPane: Fixed `IndexOutOfBoundsException` when using tooltip text on close
|
- TabbedPane: Fixed `IndexOutOfBoundsException` when using tooltip text on close
|
||||||
buttons and closing last/rightmost tab. (issue #235)
|
buttons and closing last/rightmost tab. (issue #235)
|
||||||
- Extras: Added missing export of package
|
- Extras: Added missing export of package
|
||||||
|
|||||||
@@ -410,8 +410,13 @@ public class FlatButtonUI
|
|||||||
if( model.isRollover() )
|
if( model.isRollover() )
|
||||||
return toolbarHoverBackground;
|
return toolbarHoverBackground;
|
||||||
|
|
||||||
// use background of toolbar
|
// use component background if explicitly set
|
||||||
return c.getParent().getBackground();
|
Color bg = c.getBackground();
|
||||||
|
if( isCustomBackground( bg ) )
|
||||||
|
return bg;
|
||||||
|
|
||||||
|
// do not paint background
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean def = isDefaultButton( c );
|
boolean def = isDefaultButton( c );
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ public class FlatComponentsTest
|
|||||||
JScrollPane scrollPane14 = new JScrollPane();
|
JScrollPane scrollPane14 = new JScrollPane();
|
||||||
progressBar3 = new FlatProgressBar();
|
progressBar3 = new FlatProgressBar();
|
||||||
progressBar4 = new FlatProgressBar();
|
progressBar4 = new FlatProgressBar();
|
||||||
JToolBar toolBar2 = new JToolBar();
|
FlatComponentsTest.TestToolBar toolBar2 = new FlatComponentsTest.TestToolBar();
|
||||||
JButton button9 = new JButton();
|
JButton button9 = new JButton();
|
||||||
JButton button10 = new JButton();
|
JButton button10 = new JButton();
|
||||||
JButton button11 = new JButton();
|
JButton button11 = new JButton();
|
||||||
@@ -411,7 +411,7 @@ public class FlatComponentsTest
|
|||||||
JToolTip toolTip1 = new JToolTip();
|
JToolTip toolTip1 = new JToolTip();
|
||||||
JToolTip toolTip2 = new JToolTip();
|
JToolTip toolTip2 = new JToolTip();
|
||||||
JLabel toolBarLabel = new JLabel();
|
JLabel toolBarLabel = new JLabel();
|
||||||
JToolBar toolBar1 = new JToolBar();
|
FlatComponentsTest.TestToolBar toolBar1 = new FlatComponentsTest.TestToolBar();
|
||||||
JButton button4 = new JButton();
|
JButton button4 = new JButton();
|
||||||
JButton button6 = new JButton();
|
JButton button6 = new JButton();
|
||||||
JButton button7 = new JButton();
|
JButton button7 = new JButton();
|
||||||
@@ -421,13 +421,13 @@ public class FlatComponentsTest
|
|||||||
JToggleButton toggleButton16 = new JToggleButton();
|
JToggleButton toggleButton16 = new JToggleButton();
|
||||||
JToggleButton toggleButton17 = new JToggleButton();
|
JToggleButton toggleButton17 = new JToggleButton();
|
||||||
JLabel label3 = new JLabel();
|
JLabel label3 = new JLabel();
|
||||||
JToolBar toolBar3 = new JToolBar();
|
FlatComponentsTest.TestToolBar toolBar3 = new FlatComponentsTest.TestToolBar();
|
||||||
FlatButton button26 = new FlatButton();
|
FlatButton button26 = new FlatButton();
|
||||||
FlatButton button27 = new FlatButton();
|
FlatButton button27 = new FlatButton();
|
||||||
FlatToggleButton toggleButton23 = new FlatToggleButton();
|
FlatToggleButton toggleButton23 = new FlatToggleButton();
|
||||||
FlatToggleButton toggleButton24 = new FlatToggleButton();
|
FlatToggleButton toggleButton24 = new FlatToggleButton();
|
||||||
JLabel label4 = new JLabel();
|
JLabel label4 = new JLabel();
|
||||||
JToolBar toolBar4 = new JToolBar();
|
FlatComponentsTest.TestToolBar toolBar4 = new FlatComponentsTest.TestToolBar();
|
||||||
FlatButton button28 = new FlatButton();
|
FlatButton button28 = new FlatButton();
|
||||||
FlatButton button29 = new FlatButton();
|
FlatButton button29 = new FlatButton();
|
||||||
FlatToggleButton toggleButton25 = new FlatToggleButton();
|
FlatToggleButton toggleButton25 = new FlatToggleButton();
|
||||||
@@ -1684,4 +1684,37 @@ public class FlatComponentsTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class TestToolBar --------------------------------------------------
|
||||||
|
|
||||||
|
private static class TestToolBar
|
||||||
|
extends JToolBar
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void paintComponent( Graphics g ) {
|
||||||
|
super.paintComponent( g );
|
||||||
|
|
||||||
|
if( isPaintBackgroundPattern() && isOpaque() ) {
|
||||||
|
int width = getWidth();
|
||||||
|
int height = getHeight();
|
||||||
|
|
||||||
|
g.setColor( Color.blue );
|
||||||
|
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.orange : super.getBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPaintBackgroundPattern() {
|
||||||
|
FlatTestFrame frame = (FlatTestFrame) SwingUtilities.getAncestorOfClass( FlatTestFrame.class, this );
|
||||||
|
return frame != null && frame.isPaintBackgroundPattern();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -933,7 +933,7 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 13 1 6,growy"
|
"value": "cell 4 13 1 6,growy"
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatComponentsTest$TestToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
||||||
name: "toolBar2"
|
name: "toolBar2"
|
||||||
"orientation": 1
|
"orientation": 1
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
@@ -1391,7 +1391,7 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 23"
|
"value": "cell 0 23"
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatComponentsTest$TestToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
||||||
name: "toolBar1"
|
name: "toolBar1"
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "button4"
|
name: "button4"
|
||||||
@@ -1446,7 +1446,7 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 23 5 1"
|
"value": "cell 1 23 5 1"
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatComponentsTest$TestToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
||||||
name: "toolBar3"
|
name: "toolBar3"
|
||||||
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
|
||||||
name: "button26"
|
name: "button26"
|
||||||
@@ -1479,7 +1479,7 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 23 5 1"
|
"value": "cell 1 23 5 1"
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatComponentsTest$TestToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
||||||
name: "toolBar4"
|
name: "toolBar4"
|
||||||
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
|
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
|
||||||
name: "button28"
|
name: "button28"
|
||||||
|
|||||||
Reference in New Issue
Block a user