From 9ad32125c0ee8701e76101ec96c5c3b91ea6c86b Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Tue, 26 May 2020 23:35:05 +0200 Subject: [PATCH] Window decorations: initial implementation (incomplete) (issues #47 and #82) TODO - move window - resize window - window icon - window border --- .../java/com/formdev/flatlaf/FlatLaf.java | 5 + .../com/formdev/flatlaf/IntelliJTheme.java | 4 + .../formdev/flatlaf/ui/FlatRootPaneUI.java | 186 ++++++- .../com/formdev/flatlaf/ui/FlatTitlePane.java | 306 ++++++++++++ .../com/formdev/flatlaf/FlatLaf.properties | 14 + .../testing/FlatWindowDecorationsTest.java | 467 ++++++++++++++++++ .../testing/FlatWindowDecorationsTest.jfd | 336 +++++++++++++ .../flatlaf/testing/FlatTestLaf.properties | 8 + 8 files changed, 1322 insertions(+), 4 deletions(-) create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java create mode 100644 flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.java create mode 100644 flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.jfd diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java index 2f97c616..cac59091 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java @@ -110,6 +110,11 @@ public abstract class FlatLaf public abstract boolean isDark(); + @Override + public boolean getSupportsWindowDecorations() { + return SystemInfo.IS_WINDOWS; + } + @Override public boolean isNativeLookAndFeel() { return false; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java index 5c5119ff..f6cc7240 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java @@ -492,6 +492,10 @@ public class IntelliJTheme // Slider uiKeyMapping.put( "Slider.trackWidth", "" ); // ignore (used in Material Theme UI Lite) + // TitlePane + uiKeyMapping.put( "TitlePane.infoForeground", "TitlePane.foreground" ); + uiKeyMapping.put( "TitlePane.inactiveInfoForeground", "TitlePane.inactiveForeground" ); + for( Map.Entry e : uiKeyMapping.entrySet() ) uiKeyInverseMapping.put( e.getValue(), e.getKey() ); diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java index 1f473487..6396890d 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java @@ -16,7 +16,18 @@ package com.formdev.flatlaf.ui; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.LayoutManager2; +import java.beans.PropertyChangeEvent; +import java.util.function.Function; import javax.swing.JComponent; +import javax.swing.JLayeredPane; +import javax.swing.JMenuBar; +import javax.swing.JRootPane; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRootPaneUI; @@ -28,11 +39,178 @@ import javax.swing.plaf.basic.BasicRootPaneUI; public class FlatRootPaneUI extends BasicRootPaneUI { - private static ComponentUI instance; + private JRootPane rootPane; + private JComponent titlePane; + private LayoutManager oldLayout; public static ComponentUI createUI( JComponent c ) { - if( instance == null ) - instance = new FlatRootPaneUI(); - return instance; + return new FlatRootPaneUI(); + } + + @Override + public void installUI( JComponent c ) { + super.installUI( c ); + + rootPane = (JRootPane) c; + + if( rootPane.getWindowDecorationStyle() != JRootPane.NONE ) + installClientDecorations(); + } + + @Override + public void uninstallUI( JComponent c ) { + super.uninstallUI( c ); + + uninstallClientDecorations(); + rootPane = null; + } + + private void installClientDecorations() { + // install title pane + setTitlePane( new FlatTitlePane( rootPane ) ); + + // install layout + oldLayout = rootPane.getLayout(); + rootPane.setLayout( new FlatRootLayout() ); + } + + private void uninstallClientDecorations() { + setTitlePane( null ); + + if( oldLayout != null ) { + rootPane.setLayout( oldLayout ); + oldLayout = null; + } + + if( rootPane.getWindowDecorationStyle() == JRootPane.NONE ) { + rootPane.revalidate(); + rootPane.repaint(); + } + } + + private void setTitlePane( JComponent newTitlePane ) { + JLayeredPane layeredPane = rootPane.getLayeredPane(); + + if( titlePane != null ) + layeredPane.remove( titlePane ); + + if( newTitlePane != null ) + layeredPane.add( newTitlePane, JLayeredPane.FRAME_CONTENT_LAYER ); + + titlePane = newTitlePane; + } + + @Override + public void propertyChange( PropertyChangeEvent e ) { + super.propertyChange( e ); + + switch( e.getPropertyName() ) { + case "windowDecorationStyle": + uninstallClientDecorations(); + if( rootPane.getWindowDecorationStyle() != JRootPane.NONE ) + installClientDecorations(); + break; + } + } + + //---- class FlatRootLayout ----------------------------------------------- + + private static class FlatRootLayout + implements LayoutManager2 + { + @Override public void addLayoutComponent( String name, Component comp ) {} + @Override public void addLayoutComponent( Component comp, Object constraints ) {} + @Override public void removeLayoutComponent( Component comp ) {} + @Override public void invalidateLayout( Container target ) {} + + @Override + public Dimension preferredLayoutSize( Container parent ) { + return computeLayoutSize( parent, c -> c.getPreferredSize() ); + } + + @Override + public Dimension minimumLayoutSize( Container parent ) { + return computeLayoutSize( parent, c -> c.getMinimumSize() ); + } + + @Override + public Dimension maximumLayoutSize( Container parent ) { + return new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE ); + } + + private Dimension computeLayoutSize( Container parent, Function getSizeFunc ) { + JRootPane rootPane = (JRootPane) parent; + JComponent titlePane = getTitlePane( rootPane ); + + Dimension titlePaneSize = (titlePane != null) + ? getSizeFunc.apply( titlePane ) + : new Dimension(); + Dimension menuBarSize = (rootPane.getJMenuBar() != null) + ? getSizeFunc.apply( rootPane.getJMenuBar() ) + : new Dimension(); + Dimension contentSize = (rootPane.getContentPane() != null) + ? getSizeFunc.apply( rootPane.getContentPane() ) + : rootPane.getSize(); + + int width = Math.max( titlePaneSize.width, Math.max( menuBarSize.width, contentSize.width ) ); + int height = titlePaneSize.height + menuBarSize.height + contentSize.height; + Insets insets = rootPane.getInsets(); + + return new Dimension( + width + insets.left + insets.right, + height + insets.top + insets.bottom ); + } + + private JComponent getTitlePane( JRootPane rootPane ) { + return (rootPane.getWindowDecorationStyle() != JRootPane.NONE && + rootPane.getUI() instanceof FlatRootPaneUI) + ? ((FlatRootPaneUI)rootPane.getUI()).titlePane + : null; + } + + @Override + public void layoutContainer( Container parent ) { + JRootPane rootPane = (JRootPane) parent; + + Insets insets = rootPane.getInsets(); + int x = insets.left; + int y = insets.top; + int width = rootPane.getWidth() - insets.left - insets.right; + int height = rootPane.getHeight() - insets.top - insets.bottom; + + if( rootPane.getLayeredPane() != null ) + rootPane.getLayeredPane().setBounds( x, y, width, height ); + if( rootPane.getGlassPane() != null ) + rootPane.getGlassPane().setBounds( x, y, width, height ); + + int nextY = 0; + JComponent titlePane = getTitlePane( rootPane ); + if( titlePane != null ) { + Dimension prefSize = titlePane.getPreferredSize(); + titlePane.setBounds( 0, 0, width, prefSize.height ); + nextY += prefSize.height; + } + + JMenuBar menuBar = rootPane.getJMenuBar(); + if( menuBar != null ) { + Dimension prefSize = menuBar.getPreferredSize(); + menuBar.setBounds( 0, nextY, width, prefSize.height ); + nextY += prefSize.height; + } + + Container contentPane = rootPane.getContentPane(); + if( contentPane != null ) + contentPane.setBounds( 0, nextY, width, Math.max( height - nextY, 0 ) ); + } + + @Override + public float getLayoutAlignmentX( Container target ) { + return 0; + } + + @Override + public float getLayoutAlignmentY( Container target ) { + return 0; + } } } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java new file mode 100644 index 00000000..014b5d53 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java @@ -0,0 +1,306 @@ +/* + * Copyright 2020 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 + * + * https://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.ui; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Window; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.accessibility.AccessibleContext; +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRootPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import com.formdev.flatlaf.util.UIScale; + +/** + * Provides the Flat LaF title bar. + * + * @uiDefault TitlePane.background Color + * @uiDefault TitlePane.inactiveBackground Color + * @uiDefault TitlePane.foreground Color + * @uiDefault TitlePane.inactiveForeground Color + * @uiDefault TitlePane.closeIcon Icon + * @uiDefault TitlePane.iconifyIcon Icon + * @uiDefault TitlePane.maximizeIcon Icon + * @uiDefault TitlePane.minimizeIcon Icon + * + * @author Karl Tauber + */ +class FlatTitlePane + extends JComponent +{ + private final Color activeBackground = UIManager.getColor( "TitlePane.background" ); + private final Color inactiveBackground = UIManager.getColor( "TitlePane.inactiveBackground" ); + private final Color activeForeground = UIManager.getColor( "TitlePane.foreground" ); + private final Color inactiveForeground = UIManager.getColor( "TitlePane.inactiveForeground" ); + + private final JRootPane rootPane; + + private JLabel titleLabel; + private JPanel buttonPanel; + private JButton iconifyButton; + private JButton maximizeButton; + private JButton restoreButton; + private JButton closeButton; + + private final Handler handler = new Handler(); + private Window window; + + FlatTitlePane( JRootPane rootPane ) { + this.rootPane = rootPane; + + addSubComponents(); + activeChanged( true ); + + addMouseListener( handler ); + } + + private void addSubComponents() { + titleLabel = new JLabel(); + titleLabel.setBorder( new FlatEmptyBorder( UIManager.getInsets( "TitlePane.titleMargins" ) ) ); + + createButtons(); + + setLayout( new BorderLayout( UIScale.scale( 4 ), 0 ) ); + add( titleLabel, BorderLayout.CENTER ); + add( buttonPanel, BorderLayout.EAST ); + } + + private void createButtons() { + iconifyButton = createButton( "TitlePane.iconifyIcon", "Iconify", e -> iconify() ); + maximizeButton = createButton( "TitlePane.maximizeIcon", "Maximize", e -> maximize() ); + restoreButton = createButton( "TitlePane.minimizeIcon", "Restore", e -> restore() ); + closeButton = createButton( "TitlePane.closeIcon", "Close", e -> close() ); + + buttonPanel = new JPanel(); + buttonPanel.setOpaque( false ); + buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.X_AXIS ) ); + if( rootPane.getWindowDecorationStyle() == JRootPane.FRAME ) { + // JRootPane.FRAME works only for frames (and not for dialogs) + // but at this time the owner window type is unknown (not yet added) + // so we add the iconify/maximize/restore buttons and they are hidden + // later in frameStateChanged(), which is invoked from addNotify() + + restoreButton.setVisible( false ); + + buttonPanel.add( iconifyButton ); + buttonPanel.add( maximizeButton ); + buttonPanel.add( restoreButton ); + } + buttonPanel.add( closeButton ); + } + + private JButton createButton( String iconKey, String accessibleName, ActionListener action ) { + JButton button = new JButton( UIManager.getIcon( iconKey ) ); + button.setFocusable( false ); + button.setContentAreaFilled( false ); + button.setBorder( BorderFactory.createEmptyBorder() ); + button.putClientProperty( AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName ); + button.addActionListener( action ); + return button; + } + + private void activeChanged( boolean active ) { + setBackground( active ? activeBackground : inactiveBackground ); + titleLabel.setForeground( FlatUIUtils.nonUIResource( active ? activeForeground : inactiveForeground ) ); + } + + private void frameStateChanged() { + if( window == null || rootPane.getWindowDecorationStyle() != JRootPane.FRAME ) + return; + + if( window instanceof Frame ) { + Frame frame = (Frame) window; + boolean resizable = frame.isResizable(); + boolean maximized = ((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0); + + iconifyButton.setVisible( true ); + maximizeButton.setVisible( resizable && !maximized ); + restoreButton.setVisible( resizable && maximized ); + } else { + // hide buttons because they are only supported in frames + iconifyButton.setVisible( false ); + maximizeButton.setVisible( false ); + restoreButton.setVisible( false ); + + revalidate(); + repaint(); + } + } + + @Override + public void addNotify() { + super.addNotify(); + + uninstallWindowListeners(); + + window = SwingUtilities.getWindowAncestor( this ); + if( window != null ) { + frameStateChanged(); + activeChanged( window.isActive() ); + titleLabel.setText( getWindowTitle() ); + installWindowListeners(); + } + } + + @Override + public void removeNotify() { + super.removeNotify(); + + uninstallWindowListeners(); + window = null; + } + + private String getWindowTitle() { + if( window instanceof Frame ) + return ((Frame)window).getTitle(); + if( window instanceof Dialog ) + return ((Dialog)window).getTitle(); + return null; + } + + private void installWindowListeners() { + if( window == null ) + return; + + window.addPropertyChangeListener( handler ); + window.addWindowListener( handler ); + window.addWindowStateListener( handler ); + } + + private void uninstallWindowListeners() { + if( window == null ) + return; + + window.removePropertyChangeListener( handler ); + window.removeWindowListener( handler ); + window.removeWindowStateListener( handler ); + } + + @Override + protected void paintComponent( Graphics g ) { + g.setColor( getBackground() ); + g.fillRect( 0, 0, getWidth(), getHeight() ); + } + + private void iconify() { + if( window instanceof Frame ) { + Frame frame = (Frame) window; + frame.setExtendedState( frame.getExtendedState() | Frame.ICONIFIED ); + } + } + + private void maximize() { + if( window instanceof Frame ) { + Frame frame = (Frame) window; + frame.setExtendedState( frame.getExtendedState() | Frame.MAXIMIZED_BOTH ); + } + } + + private void restore() { + if( window instanceof Frame ) { + Frame frame = (Frame) window; + int state = frame.getExtendedState(); + frame.setExtendedState( ((state & Frame.ICONIFIED) != 0) + ? (state & ~Frame.ICONIFIED) + : (state & ~Frame.MAXIMIZED_BOTH) ); + } + } + + private void close() { + if( window != null ) + window.dispatchEvent( new WindowEvent( window, WindowEvent.WINDOW_CLOSING ) ); + } + + //---- class Handler ------------------------------------------------------ + + private class Handler + extends WindowAdapter + implements PropertyChangeListener, MouseListener + { + //---- interface PropertyChangeListener ---- + + @Override + public void propertyChange( PropertyChangeEvent e ) { + switch( e.getPropertyName() ) { + case "title": + titleLabel.setText( getWindowTitle() ); + break; + + case "resizable": + if( window instanceof Frame ) + frameStateChanged(); + break; + } + } + + //---- interface WindowListener ---- + + @Override + public void windowActivated( WindowEvent e ) { + activeChanged( true ); + } + + @Override + public void windowDeactivated( WindowEvent e ) { + activeChanged( false ); + } + + @Override + public void windowStateChanged( WindowEvent e ) { + frameStateChanged(); + } + + //---- interface MouseListener ---- + + @Override + public void mouseClicked( MouseEvent e ) { + if( e.getClickCount() == 2 && + SwingUtilities.isLeftMouseButton( e ) && + window instanceof Frame && + ((Frame)window).isResizable() ) + { + // maximize/restore on double-click + Frame frame = (Frame) window; + int state = frame.getExtendedState(); + frame.setExtendedState( ((state & Frame.MAXIMIZED_BOTH) != 0) + ? (state & ~Frame.MAXIMIZED_BOTH) + : (state | Frame.MAXIMIZED_BOTH) ); + } + } + + @Override public void mousePressed( MouseEvent e ) {} + @Override public void mouseReleased( MouseEvent e ) {} + @Override public void mouseEntered( MouseEvent e ) {} + @Override public void mouseExited( MouseEvent e ) {} + } +} 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 d5c6dcb0..98094770 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -574,6 +574,20 @@ TitledBorder.titleColor=@foreground TitledBorder.border=1,1,1,1,$Separator.foreground +#---- TitlePane ---- + +TitlePane.titleMargins=3,8,3,8 +TitlePane.closeIcon=$InternalFrame.closeIcon +TitlePane.iconifyIcon=$InternalFrame.iconifyIcon +TitlePane.maximizeIcon=$InternalFrame.maximizeIcon +TitlePane.minimizeIcon=$InternalFrame.minimizeIcon + +TitlePane.background=$MenuBar.background +TitlePane.inactiveBackground=$TitlePane.background +TitlePane.foreground=@foreground +TitlePane.inactiveForeground=@disabledText + + #---- ToggleButton ---- ToggleButton.border=com.formdev.flatlaf.ui.FlatButtonBorder diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.java new file mode 100644 index 00000000..6d4efdab --- /dev/null +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.java @@ -0,0 +1,467 @@ +/* + * Copyright 2020 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 + * + * https://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.testing; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +public class FlatWindowDecorationsTest + extends FlatTestPanel +{ + public static void main( String[] args ) { + SwingUtilities.invokeLater( () -> { + // enable custom window decoration (if LaF supports it) + JFrame.setDefaultLookAndFeelDecorated( true ); + JDialog.setDefaultLookAndFeelDecorated( true ); + + FlatTestFrame frame = FlatTestFrame.create( args, "FlatWindowDecorationsTest" ); + + // WARNING: Do not this in real-world programs. +// frame.setUndecorated( true ); +// frame.getRootPane().setWindowDecorationStyle( JRootPane.FRAME ); + + frame.showFrame( FlatWindowDecorationsTest::new, panel -> ((FlatWindowDecorationsTest)panel).menuBar ); + } ); + } + + FlatWindowDecorationsTest() { + initComponents(); + } + + @Override + public void addNotify() { + super.addNotify(); + + JRootPane rootPane = getWindowRootPane(); + if( rootPane != null ) { + int style = rootPane.getWindowDecorationStyle(); + if( style == JRootPane.NONE ) + styleNoneRadioButton.setSelected( true ); + else if( style == JRootPane.FRAME ) + styleFrameRadioButton.setSelected( true ); + else if( style == JRootPane.PLAIN_DIALOG ) + stylePlainRadioButton.setSelected( true ); + else if( style == JRootPane.INFORMATION_DIALOG ) + styleInfoRadioButton.setSelected( true ); + else + throw new RuntimeException(); // not used + } + } + + private void menuBarChanged() { + Window window = SwingUtilities.windowForComponent( this ); + if( window instanceof JFrame ) { + ((JFrame)window).setJMenuBar( menuBarCheckBox.isSelected() ? menuBar : null ); + window.revalidate(); + window.repaint(); + } + } + + private void resizableChanged() { + Window window = SwingUtilities.windowForComponent( this ); + if( window instanceof Frame ) + ((Frame)window).setResizable( resizableCheckBox.isSelected() ); + } + + private void menuItemActionPerformed(ActionEvent e) { + SwingUtilities.invokeLater( () -> { + JOptionPane.showMessageDialog( this, e.getActionCommand(), "Menu Item", JOptionPane.PLAIN_MESSAGE ); + } ); + } + + private void openDialog() { + JOptionPane.showMessageDialog( this, new FlatWindowDecorationsTest() ); + } + + private void decorationStyleChanged() { + int style; + if( styleFrameRadioButton.isSelected() ) + style = JRootPane.FRAME; + else if( stylePlainRadioButton.isSelected() ) + style = JRootPane.PLAIN_DIALOG; + else if( styleInfoRadioButton.isSelected() ) + style = JRootPane.INFORMATION_DIALOG; + else if( styleErrorRadioButton.isSelected() ) + style = JRootPane.ERROR_DIALOG; + else if( styleQuestionRadioButton.isSelected() ) + style = JRootPane.QUESTION_DIALOG; + else if( styleWarningRadioButton.isSelected() ) + style = JRootPane.WARNING_DIALOG; + else if( styleColorChooserRadioButton.isSelected() ) + style = JRootPane.COLOR_CHOOSER_DIALOG; + else if( styleFileChooserRadioButton.isSelected() ) + style = JRootPane.FILE_CHOOSER_DIALOG; + else + style = JRootPane.NONE; + + JRootPane rootPane = getWindowRootPane(); + if( rootPane != null ) + rootPane.setWindowDecorationStyle( style ); + } + + private JRootPane getWindowRootPane() { + Window window = SwingUtilities.windowForComponent( this ); + if( window instanceof JFrame ) + return ((JFrame)window).getRootPane(); + else if( window instanceof JDialog ) + return ((JDialog)window).getRootPane(); + return null; + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + menuBarCheckBox = new JCheckBox(); + resizableCheckBox = new JCheckBox(); + JLabel label1 = new JLabel(); + JPanel panel1 = new JPanel(); + styleNoneRadioButton = new JRadioButton(); + styleFrameRadioButton = new JRadioButton(); + stylePlainRadioButton = new JRadioButton(); + styleInfoRadioButton = new JRadioButton(); + styleErrorRadioButton = new JRadioButton(); + styleQuestionRadioButton = new JRadioButton(); + styleWarningRadioButton = new JRadioButton(); + styleColorChooserRadioButton = new JRadioButton(); + styleFileChooserRadioButton = new JRadioButton(); + JButton openDialogButton = new JButton(); + menuBar = new JMenuBar(); + JMenu fileMenu = new JMenu(); + JMenuItem newMenuItem = new JMenuItem(); + JMenuItem openMenuItem = new JMenuItem(); + JMenuItem closeMenuItem = new JMenuItem(); + JMenuItem closeMenuItem2 = new JMenuItem(); + JMenuItem exitMenuItem = new JMenuItem(); + JMenu editMenu = new JMenu(); + JMenuItem undoMenuItem = new JMenuItem(); + JMenuItem redoMenuItem = new JMenuItem(); + JMenuItem cutMenuItem = new JMenuItem(); + JMenuItem copyMenuItem = new JMenuItem(); + JMenuItem pasteMenuItem = new JMenuItem(); + JMenuItem deleteMenuItem = new JMenuItem(); + JMenu viewMenu = new JMenu(); + JCheckBoxMenuItem checkBoxMenuItem1 = new JCheckBoxMenuItem(); + JMenu menu1 = new JMenu(); + JMenu subViewsMenu = new JMenu(); + JMenu subSubViewsMenu = new JMenu(); + JMenuItem errorLogViewMenuItem = new JMenuItem(); + JMenuItem searchViewMenuItem = new JMenuItem(); + JMenuItem projectViewMenuItem = new JMenuItem(); + JMenuItem structureViewMenuItem = new JMenuItem(); + JMenuItem propertiesViewMenuItem = new JMenuItem(); + JMenu helpMenu = new JMenu(); + JMenuItem aboutMenuItem = new JMenuItem(); + + //======== this ======== + setLayout(new MigLayout( + "ltr,insets dialog,hidemode 3", + // columns + "[left]para", + // rows + "para[]" + + "[]" + + "[]" + + "[]" + + "[]")); + + //---- menuBarCheckBox ---- + menuBarCheckBox.setText("menu bar"); + menuBarCheckBox.setSelected(true); + menuBarCheckBox.addActionListener(e -> menuBarChanged()); + add(menuBarCheckBox, "cell 0 0"); + + //---- resizableCheckBox ---- + resizableCheckBox.setText("resizable"); + resizableCheckBox.setSelected(true); + resizableCheckBox.addActionListener(e -> resizableChanged()); + add(resizableCheckBox, "cell 0 1"); + + //---- label1 ---- + label1.setText("Style:"); + add(label1, "cell 0 2"); + + //======== panel1 ======== + { + panel1.setLayout(new MigLayout( + "ltr,insets 0,hidemode 3,gap 0 0", + // columns + "[fill]", + // rows + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]")); + + //---- styleNoneRadioButton ---- + styleNoneRadioButton.setText("none"); + styleNoneRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleNoneRadioButton, "cell 0 0"); + + //---- styleFrameRadioButton ---- + styleFrameRadioButton.setText("frame"); + styleFrameRadioButton.setSelected(true); + styleFrameRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleFrameRadioButton, "cell 0 1"); + + //---- stylePlainRadioButton ---- + stylePlainRadioButton.setText("plain dialog"); + stylePlainRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(stylePlainRadioButton, "cell 0 2"); + + //---- styleInfoRadioButton ---- + styleInfoRadioButton.setText("info dialog"); + styleInfoRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleInfoRadioButton, "cell 0 3"); + + //---- styleErrorRadioButton ---- + styleErrorRadioButton.setText("error dialog"); + styleErrorRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleErrorRadioButton, "cell 0 4"); + + //---- styleQuestionRadioButton ---- + styleQuestionRadioButton.setText("question dialog"); + styleQuestionRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleQuestionRadioButton, "cell 0 5"); + + //---- styleWarningRadioButton ---- + styleWarningRadioButton.setText("warning dialog"); + styleWarningRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleWarningRadioButton, "cell 0 6"); + + //---- styleColorChooserRadioButton ---- + styleColorChooserRadioButton.setText("color chooser dialog"); + styleColorChooserRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleColorChooserRadioButton, "cell 0 7"); + + //---- styleFileChooserRadioButton ---- + styleFileChooserRadioButton.setText("file chooser dialog"); + styleFileChooserRadioButton.addActionListener(e -> decorationStyleChanged()); + panel1.add(styleFileChooserRadioButton, "cell 0 8"); + } + add(panel1, "cell 0 3"); + + //---- openDialogButton ---- + openDialogButton.setText("Open Dialog"); + openDialogButton.addActionListener(e -> openDialog()); + add(openDialogButton, "cell 0 4"); + + //======== menuBar ======== + { + + //======== fileMenu ======== + { + fileMenu.setText("File"); + fileMenu.setMnemonic('F'); + + //---- newMenuItem ---- + newMenuItem.setText("New"); + newMenuItem.setMnemonic('N'); + newMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + fileMenu.add(newMenuItem); + + //---- openMenuItem ---- + openMenuItem.setText("Open"); + openMenuItem.setMnemonic('O'); + openMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + fileMenu.add(openMenuItem); + fileMenu.addSeparator(); + + //---- closeMenuItem ---- + closeMenuItem.setText("Close"); + closeMenuItem.setMnemonic('C'); + closeMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + fileMenu.add(closeMenuItem); + + //---- closeMenuItem2 ---- + closeMenuItem2.setText("Close All"); + closeMenuItem2.addActionListener(e -> menuItemActionPerformed(e)); + fileMenu.add(closeMenuItem2); + fileMenu.addSeparator(); + + //---- exitMenuItem ---- + exitMenuItem.setText("Exit"); + exitMenuItem.setMnemonic('X'); + exitMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + fileMenu.add(exitMenuItem); + } + menuBar.add(fileMenu); + + //======== editMenu ======== + { + editMenu.setText("Edit"); + editMenu.setMnemonic('E'); + + //---- undoMenuItem ---- + undoMenuItem.setText("Undo"); + undoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + undoMenuItem.setMnemonic('U'); + undoMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + editMenu.add(undoMenuItem); + + //---- redoMenuItem ---- + redoMenuItem.setText("Redo"); + redoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + redoMenuItem.setMnemonic('R'); + redoMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + editMenu.add(redoMenuItem); + editMenu.addSeparator(); + + //---- cutMenuItem ---- + cutMenuItem.setText("Cut"); + cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + cutMenuItem.setMnemonic('C'); + editMenu.add(cutMenuItem); + + //---- copyMenuItem ---- + copyMenuItem.setText("Copy"); + copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + copyMenuItem.setMnemonic('O'); + editMenu.add(copyMenuItem); + + //---- pasteMenuItem ---- + pasteMenuItem.setText("Paste"); + pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + pasteMenuItem.setMnemonic('P'); + editMenu.add(pasteMenuItem); + editMenu.addSeparator(); + + //---- deleteMenuItem ---- + deleteMenuItem.setText("Delete"); + deleteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); + deleteMenuItem.setMnemonic('D'); + deleteMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + editMenu.add(deleteMenuItem); + } + menuBar.add(editMenu); + + //======== viewMenu ======== + { + viewMenu.setText("View"); + viewMenu.setMnemonic('V'); + + //---- checkBoxMenuItem1 ---- + checkBoxMenuItem1.setText("Show Toolbar"); + checkBoxMenuItem1.setSelected(true); + checkBoxMenuItem1.setMnemonic('T'); + checkBoxMenuItem1.addActionListener(e -> menuItemActionPerformed(e)); + viewMenu.add(checkBoxMenuItem1); + + //======== menu1 ======== + { + menu1.setText("Show View"); + menu1.setMnemonic('V'); + + //======== subViewsMenu ======== + { + subViewsMenu.setText("Sub Views"); + subViewsMenu.setMnemonic('S'); + + //======== subSubViewsMenu ======== + { + subSubViewsMenu.setText("Sub sub Views"); + subSubViewsMenu.setMnemonic('U'); + + //---- errorLogViewMenuItem ---- + errorLogViewMenuItem.setText("Error Log"); + errorLogViewMenuItem.setMnemonic('E'); + errorLogViewMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + subSubViewsMenu.add(errorLogViewMenuItem); + } + subViewsMenu.add(subSubViewsMenu); + + //---- searchViewMenuItem ---- + searchViewMenuItem.setText("Search"); + searchViewMenuItem.setMnemonic('S'); + searchViewMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + subViewsMenu.add(searchViewMenuItem); + } + menu1.add(subViewsMenu); + + //---- projectViewMenuItem ---- + projectViewMenuItem.setText("Project"); + projectViewMenuItem.setMnemonic('P'); + projectViewMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + menu1.add(projectViewMenuItem); + + //---- structureViewMenuItem ---- + structureViewMenuItem.setText("Structure"); + structureViewMenuItem.setMnemonic('T'); + structureViewMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + menu1.add(structureViewMenuItem); + + //---- propertiesViewMenuItem ---- + propertiesViewMenuItem.setText("Properties"); + propertiesViewMenuItem.setMnemonic('O'); + propertiesViewMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + menu1.add(propertiesViewMenuItem); + } + viewMenu.add(menu1); + } + menuBar.add(viewMenu); + + //======== helpMenu ======== + { + helpMenu.setText("Help"); + helpMenu.setMnemonic('H'); + + //---- aboutMenuItem ---- + aboutMenuItem.setText("About"); + aboutMenuItem.setMnemonic('A'); + aboutMenuItem.addActionListener(e -> menuItemActionPerformed(e)); + helpMenu.add(aboutMenuItem); + } + menuBar.add(helpMenu); + } + + //---- styleButtonGroup ---- + ButtonGroup styleButtonGroup = new ButtonGroup(); + styleButtonGroup.add(styleNoneRadioButton); + styleButtonGroup.add(styleFrameRadioButton); + styleButtonGroup.add(stylePlainRadioButton); + styleButtonGroup.add(styleInfoRadioButton); + styleButtonGroup.add(styleErrorRadioButton); + styleButtonGroup.add(styleQuestionRadioButton); + styleButtonGroup.add(styleWarningRadioButton); + styleButtonGroup.add(styleColorChooserRadioButton); + styleButtonGroup.add(styleFileChooserRadioButton); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JCheckBox menuBarCheckBox; + private JCheckBox resizableCheckBox; + private JRadioButton styleNoneRadioButton; + private JRadioButton styleFrameRadioButton; + private JRadioButton stylePlainRadioButton; + private JRadioButton styleInfoRadioButton; + private JRadioButton styleErrorRadioButton; + private JRadioButton styleQuestionRadioButton; + private JRadioButton styleWarningRadioButton; + private JRadioButton styleColorChooserRadioButton; + private JRadioButton styleFileChooserRadioButton; + private JMenuBar menuBar; + // JFormDesigner - End of variables declaration //GEN-END:variables +} diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.jfd new file mode 100644 index 00000000..dfaee803 --- /dev/null +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatWindowDecorationsTest.jfd @@ -0,0 +1,336 @@ +JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + auxiliary() { + "JavaCodeGenerator.defaultVariableLocal": true + } + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "ltr,insets dialog,hidemode 3" + "$columnConstraints": "[left]para" + "$rowConstraints": "para[][][][][]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "menuBarCheckBox" + "text": "menu bar" + "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuBarChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "resizableCheckBox" + "text": "resizable" + "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "resizableChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "Style:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$columnConstraints": "[fill]" + "$rowConstraints": "[][][][][][][][][]" + "$layoutConstraints": "ltr,insets 0,hidemode 3,gap 0 0" + } ) { + name: "panel1" + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleNoneRadioButton" + "text": "none" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleFrameRadioButton" + "text": "frame" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "stylePlainRadioButton" + "text": "plain dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleInfoRadioButton" + "text": "info dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleErrorRadioButton" + "text": "error dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleQuestionRadioButton" + "text": "question dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleWarningRadioButton" + "text": "warning dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleColorChooserRadioButton" + "text": "color chooser dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "styleFileChooserRadioButton" + "text": "file chooser dialog" + "$buttonGroup": new FormReference( "styleButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "decorationStyleChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 8" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "openDialogButton" + "text": "Open Dialog" + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDialog", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 450, 380 ) + } ) + add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) { + name: "menuBar" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "fileMenu" + "text": "File" + "mnemonic": 70 + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "newMenuItem" + "text": "New" + "mnemonic": 78 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "openMenuItem" + "text": "Open" + "mnemonic": 79 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator2" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "closeMenuItem" + "text": "Close" + "mnemonic": 67 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "closeMenuItem2" + "text": "Close All" + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator1" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "exitMenuItem" + "text": "Exit" + "mnemonic": 88 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "editMenu" + "text": "Edit" + "mnemonic": 69 + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "undoMenuItem" + "text": "Undo" + "accelerator": static javax.swing.KeyStroke getKeyStroke( 90, 4226, false ) + "mnemonic": 85 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "redoMenuItem" + "text": "Redo" + "accelerator": static javax.swing.KeyStroke getKeyStroke( 89, 4226, false ) + "mnemonic": 82 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator4" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "cutMenuItem" + "text": "Cut" + "accelerator": static javax.swing.KeyStroke getKeyStroke( 88, 4226, false ) + "mnemonic": 67 + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "copyMenuItem" + "text": "Copy" + "accelerator": static javax.swing.KeyStroke getKeyStroke( 67, 4226, false ) + "mnemonic": 79 + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "pasteMenuItem" + "text": "Paste" + "accelerator": static javax.swing.KeyStroke getKeyStroke( 86, 4226, false ) + "mnemonic": 80 + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator3" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "deleteMenuItem" + "text": "Delete" + "accelerator": static javax.swing.KeyStroke getKeyStroke( 127, 0, false ) + "mnemonic": 68 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "viewMenu" + "text": "View" + "mnemonic": 86 + add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { + name: "checkBoxMenuItem1" + "text": "Show Toolbar" + "selected": true + "mnemonic": 84 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "menu1" + "text": "Show View" + "mnemonic": 86 + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "subViewsMenu" + "text": "Sub Views" + "mnemonic": 83 + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "subSubViewsMenu" + "text": "Sub sub Views" + "mnemonic": 85 + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "errorLogViewMenuItem" + "text": "Error Log" + "mnemonic": 69 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "searchViewMenuItem" + "text": "Search" + "mnemonic": 83 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "projectViewMenuItem" + "text": "Project" + "mnemonic": 80 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "structureViewMenuItem" + "text": "Structure" + "mnemonic": 84 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "propertiesViewMenuItem" + "text": "Properties" + "mnemonic": 79 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + } ) + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "helpMenu" + "text": "Help" + "mnemonic": 72 + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "aboutMenuItem" + "text": "About" + "mnemonic": 65 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) ) + } ) + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 410 ) + "size": new java.awt.Dimension( 255, 30 ) + } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "styleButtonGroup" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 450 ) + } ) + } +} diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties index 9c007558..ae8aa809 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties @@ -307,6 +307,14 @@ TitledBorder.titleColor=#ff00ff TitledBorder.border=1,1,1,1,#ff00ff +#---- TitlePane ---- + +TitlePane.background=#0f0 +TitlePane.inactiveBackground=#080 +TitlePane.foreground=#00f +TitlePane.inactiveForeground=#fff + + #---- ToggleButton ---- ToggleButton.background=#ddddff