1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.util.swing; |
|
27 |
|
28 import java.awt.BorderLayout; |
|
29 import javax.swing.JPanel; |
|
30 |
|
31 /** |
|
32 * The {@code HeaderedCollapsiblePane} class is {@code JPanel} that contains a |
|
33 * {@link #getHeaderPane header pane} above a {@code #getContentPane content |
|
34 * pane} within a {@link CollapsiblePane #getCollapsiblePane} |
|
35 */ |
|
36 @SuppressWarnings({"serial"}) |
|
37 public class HeaderedCollapsiblePane extends JPanel { |
|
38 // |
|
39 // Instance data |
|
40 // |
|
41 |
|
42 private CollapsiblePane cPane; |
|
43 private JPanel contentPane; |
|
44 private JPanel headerPane; |
|
45 |
|
46 // |
|
47 // Constructors |
|
48 // |
|
49 |
|
50 public HeaderedCollapsiblePane(int gap) { |
|
51 this.cPane = cPane; |
|
52 |
|
53 contentPane = new JPanel(new BorderLayout()); |
|
54 contentPane.setOpaque(false); |
|
55 |
|
56 JPanel panel = new JPanel(new BorderLayout(gap, gap)); |
|
57 panel.setOpaque(false); |
|
58 panel.add(new Spacer(), BorderLayout.NORTH); |
|
59 panel.add(contentPane, BorderLayout.CENTER); |
|
60 |
|
61 cPane = new CollapsiblePane(panel); |
|
62 cPane.setOpaque(false); |
|
63 |
|
64 setOpaque(false); |
|
65 setLayout(new BorderLayout()); |
|
66 |
|
67 headerPane = new JPanel(new BorderLayout()); |
|
68 headerPane.setOpaque(false); |
|
69 |
|
70 add(headerPane, BorderLayout.NORTH); |
|
71 add(cPane, BorderLayout.CENTER); |
|
72 |
|
73 setCollapsed(true); |
|
74 } |
|
75 |
|
76 public HeaderedCollapsiblePane() { |
|
77 this(0); |
|
78 } |
|
79 |
|
80 // |
|
81 // HeaderedCollapsiblePane methods |
|
82 // |
|
83 |
|
84 public CollapsiblePane getCollapsiblePane() { |
|
85 return cPane; |
|
86 } |
|
87 |
|
88 /** |
|
89 * Gets a content pane, initialized with a {@code BorderLayout}. |
|
90 */ |
|
91 public JPanel getContentPane() { |
|
92 return contentPane; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Gets a header pane, initialized with a {@code BorderLayout}. |
|
97 */ |
|
98 public JPanel getHeaderPane() { |
|
99 return headerPane; |
|
100 } |
|
101 |
|
102 public void setCollapsed(boolean collapsed) { |
|
103 cPane.setCollapsed(collapsed); |
|
104 } |
|
105 } |
|