diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java index 9eb2f325..ef4bd234 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java @@ -21,6 +21,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.*; import javax.swing.border.*; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.demo.ScrollablePanel; import net.miginfocom.swing.*; @@ -63,6 +64,15 @@ public class FlatOptionPaneTest UIManager.put( "OptionPane.showIcon", showTitleBarIconCheckBox.isSelected() ); } + private void showWithCustomIcon() { + JOptionPane optionPane = new JOptionPane( "Hello world." ); + JDialog dialog = optionPane.createDialog( "With Custom Icon" ); + dialog.getRootPane().putClientProperty( FlatClientProperties.TITLE_BAR_SHOW_ICON, true ); + dialog.setIconImage( new ImageIcon( FlatOptionPaneTest.class.getResource( "/com/formdev/flatlaf/testing/test32.png" ) ).getImage() ); + dialog.setVisible( true ); + dialog.dispose(); + } + private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents ScrollablePanel panel9 = new ScrollablePanel(); @@ -75,6 +85,7 @@ public class FlatOptionPaneTest JPanel panel2 = new JPanel(); JOptionPane errorOptionPane = new JOptionPane(); errorShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel(); + JButton showWithCustomIconButton = new JButton(); JLabel informationLabel = new JLabel(); JPanel panel3 = new JPanel(); JOptionPane informationOptionPane = new JOptionPane(); @@ -173,6 +184,11 @@ public class FlatOptionPaneTest errorShowDialogLabel.setOptionPane(errorOptionPane); panel9.add(errorShowDialogLabel, "cell 1 1"); + //---- showWithCustomIconButton ---- + showWithCustomIconButton.setText("Show with custom icon"); + showWithCustomIconButton.addActionListener(e -> showWithCustomIcon()); + panel9.add(showWithCustomIconButton, "cell 2 1"); + //---- informationLabel ---- informationLabel.setText("Information"); panel9.add(informationLabel, "cell 0 2"); diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd index 26deae19..87e72473 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" +JFDML JFormDesigner: "8.2.3.0.386" Java: "21" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -83,6 +83,13 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1" } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "showWithCustomIconButton" + "text": "Show with custom icon" + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showWithCustomIcon", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 1" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "informationLabel" "text": "Information"