diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneAbstractIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneAbstractIcon.java new file mode 100644 index 00000000..0e748e80 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneAbstractIcon.java @@ -0,0 +1,59 @@ +/* + * Copyright 2019 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.icons; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Path2D; +import javax.swing.UIManager; + +/** + * Base class for icons for {@link javax.swing.JOptionPane}. + * + * @uiDefault OptionPane.icon.foreground Color + * + * @author Karl Tauber + */ +public abstract class FlatOptionPaneAbstractIcon + extends FlatAbstractIcon +{ + protected final Color foreground = UIManager.getColor( "OptionPane.icon.foreground" ); + + protected FlatOptionPaneAbstractIcon( String colorKey ) { + super( 32, 32, UIManager.getColor( colorKey ) ); + } + + @Override + protected void paintIcon( Component c, Graphics2D g ) { + if( foreground != null ) { + g.fill( createOutside() ); + + g.setColor( foreground ); + g.fill( createInside() ); + } else { + Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + path.append( createOutside(), false ); + path.append( createInside(), false ); + g.fill( path ); + } + } + + protected abstract Shape createOutside(); + protected abstract Shape createInside(); +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneErrorIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneErrorIcon.java new file mode 100644 index 00000000..2efd8c0a --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneErrorIcon.java @@ -0,0 +1,60 @@ +/* + * Copyright 2019 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.icons; + +import java.awt.Shape; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; + +/** + * "Error" icon for {@link javax.swing.JOptionPane}. + * + * @uiDefault OptionPane.icon.errorColor Color + * + * @author Karl Tauber + */ +public class FlatOptionPaneErrorIcon + extends FlatOptionPaneAbstractIcon +{ + public FlatOptionPaneErrorIcon() { + super( "OptionPane.icon.errorColor" ); + } + + /* + + + + + + + + */ + + @Override + protected Shape createOutside() { + return new Ellipse2D.Float( 2, 2, 28, 28 ); + } + + @Override + protected Shape createInside() { + Path2D inside = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + inside.append( new Rectangle2D.Float( 14, 7, 4, 11 ), false ); + inside.append( new Rectangle2D.Float( 14, 21, 4, 4 ), false ); + return inside; + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneInformationIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneInformationIcon.java new file mode 100644 index 00000000..7d45dabf --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneInformationIcon.java @@ -0,0 +1,60 @@ +/* + * Copyright 2019 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.icons; + +import java.awt.Shape; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; + +/** + * "Information" icon for {@link javax.swing.JOptionPane}. + * + * @uiDefault OptionPane.icon.informationColor Color + * + * @author Karl Tauber + */ +public class FlatOptionPaneInformationIcon + extends FlatOptionPaneAbstractIcon +{ + public FlatOptionPaneInformationIcon() { + super( "OptionPane.icon.informationColor" ); + } + + /* + + + + + + + + */ + + @Override + protected Shape createOutside() { + return new Ellipse2D.Float( 2, 2, 28, 28 ); + } + + @Override + protected Shape createInside() { + Path2D inside = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + inside.append( new Rectangle2D.Float( 14, 14, 4, 11 ), false ); + inside.append( new Rectangle2D.Float( 14, 7, 4, 4 ), false ); + return inside; + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneQuestionIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneQuestionIcon.java new file mode 100644 index 00000000..9994ace8 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneQuestionIcon.java @@ -0,0 +1,72 @@ +/* + * Copyright 2019 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.icons; + +import java.awt.Shape; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; + +/** + * "Question" icon for {@link javax.swing.JOptionPane}. + * + * @uiDefault OptionPane.icon.questionColor Color + * + * @author Karl Tauber + */ +public class FlatOptionPaneQuestionIcon + extends FlatOptionPaneAbstractIcon +{ + public FlatOptionPaneQuestionIcon() { + super( "OptionPane.icon.questionColor" ); + } + + /* + + + + + + + + */ + + @Override + protected Shape createOutside() { + return new Ellipse2D.Float( 2, 2, 28, 28 ); + } + + @Override + protected Shape createInside() { + Path2D q = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + q.moveTo( 14, 20 ); + q.lineTo( 18, 20 ); + q.curveTo( 18, 16, 23, 16, 23, 12 ); + q.curveTo( 23, 8, 20, 6, 16, 6 ); + q.curveTo( 12, 6, 9, 8, 9, 12 ); + q.curveTo( 9, 12, 13, 12, 13, 12 ); + q.curveTo( 13, 10, 14, 9, 16, 9 ); + q.curveTo( 18, 9, 19, 10, 19, 12 ); + q.curveTo( 19, 15, 14, 15, 14, 20 ); + q.closePath(); + + Path2D inside = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + inside.append( new Rectangle2D.Float( 14, 22, 4, 4 ), false ); + inside.append( q, false ); + return inside; + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneWarningIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneWarningIcon.java new file mode 100644 index 00000000..2c4ec17a --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatOptionPaneWarningIcon.java @@ -0,0 +1,63 @@ +/* + * Copyright 2019 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.icons; + +import java.awt.Shape; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; + +/** + * "Warning" icon for {@link javax.swing.JOptionPane}. + * + * @uiDefault OptionPane.icon.warningColor Color + * + * @author Karl Tauber + */ +public class FlatOptionPaneWarningIcon + extends FlatOptionPaneAbstractIcon +{ + public FlatOptionPaneWarningIcon() { + super( "OptionPane.icon.warningColor" ); + } + + /* + + + + + + + + */ + + @Override + protected Shape createOutside() { + Path2D outside = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + outside.moveTo( 16, 2 ); + outside.lineTo( 31, 28 ); + outside.lineTo( 1, 28 ); + return outside; + } + + @Override + protected Shape createInside() { + Path2D inside = new Path2D.Float( Path2D.WIND_EVEN_ODD ); + inside.append( new Rectangle2D.Float( 14, 10, 4, 8 ), false ); + inside.append( new Rectangle2D.Float( 14, 21, 4, 4 ), false ); + return inside; + } +} diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index 81a540e7..9fc537a8 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -131,6 +131,15 @@ MenuItemCheckBox.icon.checkmarkColor=A7A7A7 MenuItemCheckBox.icon.disabledCheckmarkColor=606060 +#---- OptionPane ---- + +OptionPane.icon.errorColor=C75450 +OptionPane.icon.informationColor=3592C4 +OptionPane.icon.questionColor=3592C4 +OptionPane.icon.warningColor=F0A732 +OptionPane.icon.foreground=null + + #---- PopupMenu ---- PopupMenu.borderColor=515151 diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 4ef71a53..caf768be 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -128,6 +128,14 @@ MenuItem.border=com.formdev.flatlaf.ui.FlatMarginBorder MenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon +#---- OptionPane ---- + +OptionPane.errorIcon=com.formdev.flatlaf.icons.FlatOptionPaneErrorIcon +OptionPane.informationIcon=com.formdev.flatlaf.icons.FlatOptionPaneInformationIcon +OptionPane.questionIcon=com.formdev.flatlaf.icons.FlatOptionPaneQuestionIcon +OptionPane.warningIcon=com.formdev.flatlaf.icons.FlatOptionPaneWarningIcon + + #---- PasswordField ---- PasswordField.border=com.formdev.flatlaf.ui.FlatBorder diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index da6b23cd..a408469c 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -131,6 +131,15 @@ MenuItemCheckBox.icon.checkmarkColor=4D89C9 MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB +#---- OptionPane ---- + +OptionPane.icon.errorColor=DB5860 +OptionPane.icon.informationColor=389FD6 +OptionPane.icon.questionColor=389FD6 +OptionPane.icon.warningColor=EDA200 +OptionPane.icon.foreground=null + + #---- PopupMenu ---- PopupMenu.borderColor=cdcdcd diff --git a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties index 8c785457..38587305 100644 --- a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties +++ b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties @@ -126,6 +126,15 @@ MenuItemCheckBox.icon.checkmarkColor=4D89C9 MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB +#---- OptionPane ---- + +OptionPane.icon.errorColor=ff0000 +OptionPane.icon.informationColor=00ff00 +OptionPane.icon.questionColor=0000ff +OptionPane.icon.warningColor=ffcc00 +OptionPane.icon.foreground=ffffff + + #---- PopupMenu ---- PopupMenu.borderColor=0000ff diff --git a/flatlaf-core/svg/FlatLaf Icons.sketch b/flatlaf-core/svg/FlatLaf Icons.sketch index 6193699f..4f5261a2 100644 Binary files a/flatlaf-core/svg/FlatLaf Icons.sketch and b/flatlaf-core/svg/FlatLaf Icons.sketch differ diff --git a/flatlaf-core/svg/OptionPaneErrorIcon.svg b/flatlaf-core/svg/OptionPaneErrorIcon.svg new file mode 100644 index 00000000..500286c3 --- /dev/null +++ b/flatlaf-core/svg/OptionPaneErrorIcon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/flatlaf-core/svg/OptionPaneInformationIcon.svg b/flatlaf-core/svg/OptionPaneInformationIcon.svg new file mode 100644 index 00000000..f418a778 --- /dev/null +++ b/flatlaf-core/svg/OptionPaneInformationIcon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/flatlaf-core/svg/OptionPaneQuestionIcon.svg b/flatlaf-core/svg/OptionPaneQuestionIcon.svg new file mode 100644 index 00000000..a4de4ac0 --- /dev/null +++ b/flatlaf-core/svg/OptionPaneQuestionIcon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/flatlaf-core/svg/OptionPaneWarningIcon.svg b/flatlaf-core/svg/OptionPaneWarningIcon.svg new file mode 100644 index 00000000..30a91c7a --- /dev/null +++ b/flatlaf-core/svg/OptionPaneWarningIcon.svg @@ -0,0 +1,7 @@ + + + + + + +