Skip to content

Commit

Permalink
Testing: added tab with random background color to FlatContainerTest …
Browse files Browse the repository at this point in the history
…and FlatJideOssContainerTest
  • Loading branch information
DevCharly committed Mar 23, 2024
1 parent ec76448 commit 3b3d7d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.Random;
import javax.swing.*;
import javax.swing.border.*;
import com.formdev.flatlaf.FlatLaf;
Expand Down Expand Up @@ -178,6 +179,20 @@ private void addTab( FlatTabbedPane tabbedPane ) {
tabbedPane.addTab( "Tab 4", new JLabel( "non-opaque content", SwingConstants.CENTER ) );
break;

case 4:
tabbedPane.addTab( "Tab 5", new JLabel( "random background content", SwingConstants.CENTER ) {
Random random = new Random();

@Override
protected void paintComponent( Graphics g ) {
g.setColor( new Color( random.nextInt() ) );
g.fillRect( 0, 0, getWidth(), getHeight() );

super.paintComponent( g );
}
} );
break;

default:
int index = tabbedPane.getTabCount() + 1;
tabbedPane.addTab( "Tab " + index, createTab( "tab content " + index ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.formdev.flatlaf.testing.jideoss;

import java.awt.*;
import java.util.Random;
import javax.swing.*;
import javax.swing.border.*;
import com.formdev.flatlaf.FlatClientProperties;
Expand Down Expand Up @@ -140,6 +141,20 @@ private void addTab( JideTabbedPane tabbedPane ) {
tabbedPane.addTab( "Tab 4", new JLabel( "non-opaque content", SwingConstants.CENTER ) );
break;

case 4:
tabbedPane.addTab( "Tab 5", new JLabel( "random background content", SwingConstants.CENTER ) {
Random random = new Random();

@Override
protected void paintComponent( Graphics g ) {
g.setColor( new Color( random.nextInt() ) );
g.fillRect( 0, 0, getWidth(), getHeight() );

super.paintComponent( g );
}
} );
break;

default:
int index = tabbedPane.getTabCount() + 1;
tabbedPane.addTab( "Tab " + index, createTab( "tab content " + index ) );
Expand Down

0 comments on commit 3b3d7d7

Please sign in to comment.