From 63193feebe22a71b3ccae993baf45b2b87d124cd Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 21 Jan 2021 00:14:42 +0100 Subject: [PATCH] JIDE: JidePopupMenu: - added test to FlatJideOssTest - updated README.md and CHANGELOG.md (PR #246) --- CHANGELOG.md | 4 ++ flatlaf-jide-oss/README.md | 1 + .../testing/jideoss/FlatJideOssTest.java | 41 ++++++++++++++----- .../testing/jideoss/FlatJideOssTest.jfd | 23 ++++++++--- 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dc5cc4b..8119041a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ FlatLaf Change Log ## 1.0-rc2-SNAPSHOT +#### New features and improvements + +- JIDE Common Layer: Support `JidePopupMenu`. + #### Fixed bugs - CheckBox and RadioButton: Fill component background as soon as background diff --git a/flatlaf-jide-oss/README.md b/flatlaf-jide-oss/README.md index 2e8e4a14..d6235e47 100644 --- a/flatlaf-jide-oss/README.md +++ b/flatlaf-jide-oss/README.md @@ -6,6 +6,7 @@ This addon for FlatLaf adds support for **some** Following JIDE Common Layer components are currently supported by this addon: +- `JidePopupMenu` - `JideTabbedPane` - `RangeSlider` - `TristateCheckBox` diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.java index b9c8e66b..953f4ff4 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.java @@ -84,18 +84,27 @@ public class FlatJideOssTest } } - private void showJidePopupButtonActionPerformed( ActionEvent e ) { + private void showJidePopup( ActionEvent e ) { Component invoker = (Component) e.getSource(); JPanel panel = new JPanel( new MigLayout() ); panel.add( new JLabel( "Name:") ); panel.add( new JTextField( 20 ) ); - JidePopup popupMenu = new JidePopup(); - popupMenu.add( panel ); - popupMenu.setDetached( true ); - popupMenu.setOwner( invoker ); - popupMenu.showPopup(); + JidePopup popup = new JidePopup(); + popup.add( panel ); + popup.setDetached( true ); + popup.setOwner( invoker ); + popup.showPopup(); + } + + private void showJidePopupMenu( ActionEvent e ) { + Component invoker = (Component) e.getSource(); + + JidePopupMenu popupMenu = new JidePopupMenu(); + for( int i = 1; i <= 100; i++ ) + popupMenu.add( "menu item " + i ); + popupMenu.show( invoker, 0, invoker.getHeight() ); } private void tristateCheckBox1Changed() { @@ -139,6 +148,8 @@ public class FlatJideOssTest JPanel panel10 = new JPanel(); JLabel jidePopupLabel = new JLabel(); JButton showJidePopupButton = new JButton(); + JLabel jidePopupMenuLabel = new JLabel(); + JButton showJidePopupMenuButton = new JButton(); JLabel label9 = new JLabel(); tristateCheckBox1 = new TristateCheckBox(); triStateLabel1 = new JLabel(); @@ -314,6 +325,7 @@ public class FlatJideOssTest "[fill]", // rows "[]" + + "[]" + "[]")); //---- jidePopupLabel ---- @@ -322,22 +334,31 @@ public class FlatJideOssTest //---- showJidePopupButton ---- showJidePopupButton.setText("show JidePopup"); - showJidePopupButton.addActionListener(e -> showJidePopupButtonActionPerformed(e)); + showJidePopupButton.addActionListener(e -> showJidePopup(e)); panel10.add(showJidePopupButton, "cell 1 0"); + //---- jidePopupMenuLabel ---- + jidePopupMenuLabel.setText("JidePopupMenu:"); + panel10.add(jidePopupMenuLabel, "cell 0 1"); + + //---- showJidePopupMenuButton ---- + showJidePopupMenuButton.setText("show JidePopupMenu"); + showJidePopupMenuButton.addActionListener(e -> showJidePopupMenu(e)); + panel10.add(showJidePopupMenuButton, "cell 1 1"); + //---- label9 ---- label9.setText("TristateCheckBox:"); - panel10.add(label9, "cell 0 1"); + panel10.add(label9, "cell 0 2"); //---- tristateCheckBox1 ---- tristateCheckBox1.setText("three states"); tristateCheckBox1.addActionListener(e -> tristateCheckBox1Changed()); - panel10.add(tristateCheckBox1, "cell 1 1"); + panel10.add(tristateCheckBox1, "cell 1 2"); //---- triStateLabel1 ---- triStateLabel1.setText("text"); triStateLabel1.setEnabled(false); - panel10.add(triStateLabel1, "cell 2 1"); + panel10.add(triStateLabel1, "cell 2 2"); } panel9.add(panel10, cc.xy(1, 9)); } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.jfd index ff340059..74282ca6 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssTest.jfd @@ -195,7 +195,7 @@ new FormModel { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 3 0 3 3,hidemode 3" "$columnConstraints": "[fill][fill][fill]" - "$rowConstraints": "[][]" + "$rowConstraints": "[][][]" } ) { name: "panel10" add( new FormComponent( "javax.swing.JLabel" ) { @@ -207,15 +207,28 @@ new FormModel { add( new FormComponent( "javax.swing.JButton" ) { name: "showJidePopupButton" "text": "show JidePopup" - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showJidePopupButtonActionPerformed", true ) ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showJidePopup", true ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "jidePopupMenuLabel" + "text": "JidePopupMenu:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "showJidePopupMenuButton" + "text": "show JidePopupMenu" + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showJidePopupMenu", true ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label9" "text": "TristateCheckBox:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 1" + "value": "cell 0 2" } ) add( new FormComponent( "com.jidesoft.swing.TristateCheckBox" ) { name: "tristateCheckBox1" @@ -225,7 +238,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tristateCheckBox1Changed", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 1" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "triStateLabel1" @@ -235,7 +248,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 1" + "value": "cell 2 2" } ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridY": 9