01: /*
02: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
03: * http://www.jaspersoft.com.
04: *
05: * Unless you have purchased a commercial license agreement from JasperSoft,
06: * the following license terms apply:
07: *
08: * This program is free software; you can redistribute it and/or modify
09: * it under the terms of the GNU General Public License version 2 as published by
10: * the Free Software Foundation.
11: *
12: * This program is distributed WITHOUT ANY WARRANTY; and without the
13: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14: * See the 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, see http://www.gnu.org/licenses/gpl.txt
18: * or write to:
19: *
20: * Free Software Foundation, Inc.,
21: * 59 Temple Place - Suite 330,
22: * Boston, MA USA 02111-1307
23: *
24: *
25: *
26: *
27: * JListView.java
28: *
29: * Created on 8 ottobre 2004, 2.55
30: *
31: */
32:
33: package it.businesslogic.ireport.gui.listview;
34:
35: import java.awt.*;
36: import javax.swing.*;
37: import javax.swing.event.*;
38:
39: public class JListView extends JPanel implements ChangeListener {
40: protected JScrollPane scroll;
41: private ScrollableList list;
42:
43: int listLayout = JList.HORIZONTAL_WRAP;
44:
45: public JListView() {
46: setLayout(new BorderLayout());
47:
48: add(BorderLayout.CENTER, scroll = new JScrollPane(
49: list = new ScrollableList()));
50: scroll.getViewport().setBackground(getList().getBackground());
51: stateChanged(new ChangeEvent(this ));
52: }
53:
54: public void stateChanged(ChangeEvent event) {
55: getList().setLayoutOrientation(listLayout);
56: if (listLayout == JList.VERTICAL) {
57: scroll
58: .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
59: scroll
60: .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
61: }
62: if (listLayout == JList.VERTICAL_WRAP) {
63: scroll
64: .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
65: scroll
66: .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
67: }
68: if (listLayout == JList.HORIZONTAL_WRAP) {
69: scroll
70: .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
71: scroll
72: .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
73: }
74: scroll.revalidate();
75: }
76:
77: public ScrollableList getList() {
78: return list;
79: }
80:
81: public void setList(ScrollableList list) {
82: this.list = list;
83: }
84:
85: }
|