01: /*
02: * Copyright (C) 2004 Nicky BRAMANTE
03: *
04: * This file is part of FreeQueryBuilder
05: *
06: * FreeQueryBuilder is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: * Send questions or suggestions to nickyb@interfree.it
21: */
22:
23: package it.frb.admin;
24:
25: import java.awt.Color;
26:
27: import javax.swing.JComponent;
28: import javax.swing.JLabel;
29: import javax.swing.JScrollPane;
30:
31: import javax.swing.border.Border;
32: import javax.swing.border.CompoundBorder;
33: import javax.swing.border.EmptyBorder;
34:
35: public class DefaultScrollPane extends DefaultPanel {
36: //private final static Border hideBottomLine = new CustomLineBorder(true,true,false,true);
37: private final static Color headerbackground = new Color(204, 204,
38: 255);
39:
40: private JScrollPane scroll;
41:
42: public DefaultScrollPane(String header, JComponent view,
43: boolean opaque) {
44: this (new JLabel(header), view, opaque);
45: }
46:
47: public DefaultScrollPane(JComponent header, JComponent view,
48: boolean opaque) {
49: header.setOpaque(opaque);
50: header.setBorder(UIUtilities.NO_BORDER);
51: for (int i = 0; i < header.getComponentCount(); i++) {
52: if (header.getComponent(i) instanceof JComponent) {
53: JComponent innerheader = (JComponent) header
54: .getComponent(i);
55: innerheader.setBorder(UIUtilities.NO_BORDER);
56: innerheader.setOpaque(opaque);
57: }
58: }
59:
60: DefaultPanel headerpane = new DefaultPanel();
61: //headerpane.setBorder(new CompoundBorder(hideBottomLine, new EmptyBorder(1,1,1,1)));
62: if (!opaque)
63: headerpane.setBackground(headerbackground);
64: headerpane.setCenterComponent(header);
65:
66: setNorthComponent(headerpane);
67: setView(view);
68: }
69:
70: public void setView(JComponent view) {
71: setCenterComponent(scroll = new JScrollPane(view));
72: }
73:
74: public void setHorizontalScrollBarVisible(boolean b) {
75: scroll
76: .setHorizontalScrollBarPolicy(b ? JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
77: : JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
78: }
79:
80: public void setVerticalScrollBarVisible(boolean b) {
81: scroll
82: .setVerticalScrollBarPolicy(b ? JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
83: : JScrollPane.VERTICAL_SCROLLBAR_NEVER);
84: }
85: }
|