File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .awt .*;
2+ import javax .swing .*;
3+ import javax .swing .border .*;
4+
5+ public class AlphaContainerDemo
6+ {
7+ public static void main (String [] args )
8+ {
9+ SwingUtilities .invokeLater (new Runnable () {
10+ public void run () {
11+ createAndShowGUI ();
12+ }
13+ });
14+ }
15+
16+ public static void createAndShowGUI ()
17+ {
18+ JComponent west = createPanel ("Painting Artifacts" );
19+ JComponent east = new AlphaContainer ( createPanel ("Using AlphaContainer" ) );
20+
21+ JFrame frame = new JFrame ("Backgrounds With Transparency" );
22+ frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
23+ frame .add (west , BorderLayout .WEST );
24+ frame .add (east , BorderLayout .EAST );
25+ frame .pack ();
26+ frame .setLocationRelativeTo (null );
27+ frame .setVisible (true );
28+ }
29+
30+ public static JPanel createPanel (String text )
31+ {
32+ JPanel panel = new JPanel ( new GridLayout (0 , 1 ));
33+ panel .setBorder ( new TitledBorder (text ) );
34+ panel .setBackground ( new Color (255 , 0 , 0 , 20 ) );
35+
36+ for (int i = 0 ; i < 5 ; i ++)
37+ {
38+ JCheckBox checkBox = new JCheckBox ("Check Box " + i );
39+ checkBox .setOpaque (false );
40+ panel .add (checkBox );
41+ }
42+
43+ panel .setPreferredSize ( new Dimension (200 , 200 ) );
44+ return panel ;
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments