FlatContainerTest: always use for-loop to modify all tabbed panes

This commit is contained in:
Karl Tauber
2020-11-01 15:59:47 +01:00
parent a47565afec
commit 9b8df64c35

View File

@@ -58,10 +58,8 @@ public class FlatContainerTest
private void tabScrollChanged() { private void tabScrollChanged() {
int tabLayoutPolicy = tabScrollCheckBox.isSelected() ? JTabbedPane.SCROLL_TAB_LAYOUT : JTabbedPane.WRAP_TAB_LAYOUT; int tabLayoutPolicy = tabScrollCheckBox.isSelected() ? JTabbedPane.SCROLL_TAB_LAYOUT : JTabbedPane.WRAP_TAB_LAYOUT;
tabbedPane1.setTabLayoutPolicy( tabLayoutPolicy ); for( JTabbedPane tabbedPane : allTabbedPanes )
tabbedPane2.setTabLayoutPolicy( tabLayoutPolicy ); tabbedPane.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane3.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
int tabCount = (Integer) tabCountSpinner.getValue(); int tabCount = (Integer) tabCountSpinner.getValue();
if( tabLayoutPolicy == JTabbedPane.SCROLL_TAB_LAYOUT && tabCount == 4 ) if( tabLayoutPolicy == JTabbedPane.SCROLL_TAB_LAYOUT && tabCount == 4 )
@@ -86,17 +84,13 @@ public class FlatContainerTest
} }
private void putTabbedPanesClientProperty( String key, Object value ) { private void putTabbedPanesClientProperty( String key, Object value ) {
tabbedPane1.putClientProperty( key, value ); for( JTabbedPane tabbedPane : allTabbedPanes )
tabbedPane2.putClientProperty( key, value ); tabbedPane.putClientProperty( key, value );
tabbedPane3.putClientProperty( key, value );
tabbedPane4.putClientProperty( key, value );
} }
private void tabCountChanged() { private void tabCountChanged() {
tabCountChanged( tabbedPane1 ); for( JTabbedPane tabbedPane : allTabbedPanes )
tabCountChanged( tabbedPane2 ); tabCountChanged( tabbedPane );
tabCountChanged( tabbedPane3 );
tabCountChanged( tabbedPane4 );
} }
private void tabCountChanged( JTabbedPane tabbedPane ) { private void tabCountChanged( JTabbedPane tabbedPane ) {
@@ -156,10 +150,8 @@ public class FlatContainerTest
} }
private void tabIconsChanged() { private void tabIconsChanged() {
setTabIcons( tabbedPane1 ); for( JTabbedPane tabbedPane : allTabbedPanes )
setTabIcons( tabbedPane2 ); setTabIcons( tabbedPane );
setTabIcons( tabbedPane3 );
setTabIcons( tabbedPane4 );
tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() ); tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() );
} }
@@ -201,17 +193,13 @@ public class FlatContainerTest
? new MatteBorder( 10, 20, 25, 35, Color.green ) ? new MatteBorder( 10, 20, 25, 35, Color.green )
: null; : null;
tabbedPane1.setBorder( border ); for( JTabbedPane tabbedPane : allTabbedPanes )
tabbedPane2.setBorder( border ); tabbedPane.setBorder( border );
tabbedPane3.setBorder( border );
tabbedPane4.setBorder( border );
} }
private void customTabsChanged() { private void customTabsChanged() {
customTabsChanged( tabbedPane1 ); for( JTabbedPane tabbedPane : allTabbedPanes )
customTabsChanged( tabbedPane2 ); customTabsChanged( tabbedPane );
customTabsChanged( tabbedPane3 );
customTabsChanged( tabbedPane4 );
} }
private void customTabsChanged( JTabbedPane tabbedPane ) { private void customTabsChanged( JTabbedPane tabbedPane ) {
@@ -242,10 +230,8 @@ public class FlatContainerTest
} }
private void htmlTabsChanged() { private void htmlTabsChanged() {
htmlTabsChanged( tabbedPane1 ); for( JTabbedPane tabbedPane : allTabbedPanes )
htmlTabsChanged( tabbedPane2 ); htmlTabsChanged( tabbedPane );
htmlTabsChanged( tabbedPane3 );
htmlTabsChanged( tabbedPane4 );
} }
private void htmlTabsChanged( JTabbedPane tabbedPane ) { private void htmlTabsChanged( JTabbedPane tabbedPane ) {
@@ -298,10 +284,8 @@ public class FlatContainerTest
} }
private void tabBackForegroundChanged() { private void tabBackForegroundChanged() {
tabBackForegroundChanged( tabbedPane1 ); for( JTabbedPane tabbedPane : allTabbedPanes )
tabBackForegroundChanged( tabbedPane2 ); tabBackForegroundChanged( tabbedPane );
tabBackForegroundChanged( tabbedPane3 );
tabBackForegroundChanged( tabbedPane4 );
} }
private void tabBackForegroundChanged( JTabbedPane tabbedPane ) { private void tabBackForegroundChanged( JTabbedPane tabbedPane ) {
@@ -322,8 +306,7 @@ public class FlatContainerTest
} }
private void leadingTrailingComponentChanged( boolean enabled, String key, String text, int gap ) { private void leadingTrailingComponentChanged( boolean enabled, String key, String text, int gap ) {
JTabbedPane[] tabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 }; for( JTabbedPane tabbedPane : allTabbedPanes ) {
for( JTabbedPane tabbedPane : tabbedPanes ) {
JComponent c = null; JComponent c = null;
if( enabled ) { if( enabled ) {
c = new JLabel( text ); c = new JLabel( text );
@@ -354,8 +337,7 @@ public class FlatContainerTest
private void secondTabClosableChanged() { private void secondTabClosableChanged() {
Boolean value = secondTabClosableCheckBox.getValue(); Boolean value = secondTabClosableCheckBox.getValue();
JTabbedPane[] tabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 }; for( JTabbedPane tabbedPane : allTabbedPanes ) {
for( JTabbedPane tabbedPane : tabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) { if( tabbedPane.getTabCount() > 1 ) {
Component c = tabbedPane.getComponentAt( 1 ); Component c = tabbedPane.getComponentAt( 1 );
((JComponent)c).putClientProperty( TABBED_PANE_TAB_CLOSABLE, value ); ((JComponent)c).putClientProperty( TABBED_PANE_TAB_CLOSABLE, value );
@@ -381,8 +363,7 @@ public class FlatContainerTest
private void secondTabWiderChanged() { private void secondTabWiderChanged() {
Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null; Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null;
JTabbedPane[] tabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 }; for( JTabbedPane tabbedPane : allTabbedPanes ) {
for( JTabbedPane tabbedPane : tabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) { if( tabbedPane.getTabCount() > 1 ) {
Component c = tabbedPane.getComponentAt( 1 ); Component c = tabbedPane.getComponentAt( 1 );
((JComponent)c).putClientProperty( TABBED_PANE_TAB_INSETS, insets ); ((JComponent)c).putClientProperty( TABBED_PANE_TAB_INSETS, insets );
@@ -758,6 +739,8 @@ public class FlatContainerTest
} }
add(panel9, "cell 0 0"); add(panel9, "cell 0 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
allTabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 };
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
@@ -794,6 +777,8 @@ public class FlatContainerTest
private JCheckBox maximumTabWidthCheckBox; private JCheckBox maximumTabWidthCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
private JTabbedPane[] allTabbedPanes;
//---- class Tab1Panel ---------------------------------------------------- //---- class Tab1Panel ----------------------------------------------------
private static class Panel1 private static class Panel1