source: trunk/gli/src/org/greenstone/gatherer/gui/DoubleImageButton.java@ 6822

Last change on this file since 6822 was 6318, checked in by jmt12, 21 years ago

Changed JButtons for GLIButtons, which know whether they should paint their background depending on what platform they are run on, and finished keyboard shortcuts

  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37package org.greenstone.gatherer.gui;
38
39import java.awt.*;
40import javax.swing.*;
41import org.greenstone.gatherer.util.Utility;
42
43/** A button that allows for an icon at both the left and right sides. */
44public class DoubleImageButton
45 extends JButton {
46
47 static final private Dimension SIZE = new Dimension(160, 25);
48
49 private JLabel west_disabled_icon_label;
50 private JLabel east_disabled_icon_label;
51 private JLabel west_enabled_icon_label;
52 private JLabel east_enabled_icon_label;
53
54 public DoubleImageButton(String title, ImageIcon enabled_icon, ImageIcon disabled_icon) {
55 super(title);
56 setOpaque(!Utility.isMac());
57 setPreferredSize(SIZE);
58
59 west_disabled_icon_label = new JLabel(disabled_icon);
60 east_disabled_icon_label = new JLabel(disabled_icon);
61 west_enabled_icon_label = new JLabel(enabled_icon);
62 east_enabled_icon_label = new JLabel(enabled_icon);
63
64 setEnabled(false);
65 setLayout(new BorderLayout());
66 add(west_disabled_icon_label, BorderLayout.WEST);
67 add(west_disabled_icon_label, BorderLayout.EAST);
68 }
69
70 public void setEnabled(boolean enabled) {
71 super.setEnabled(enabled);
72 if(enabled) {
73 remove(west_disabled_icon_label);
74 remove(east_disabled_icon_label);
75 add(west_enabled_icon_label, BorderLayout.WEST);
76 add(east_enabled_icon_label, BorderLayout.EAST);
77 }
78 else {
79 remove(west_enabled_icon_label);
80 remove(east_enabled_icon_label);
81 add(west_disabled_icon_label, BorderLayout.WEST);
82 add(east_disabled_icon_label, BorderLayout.EAST);
83 }
84 validate();
85 }
86}
Note: See TracBrowser for help on using the repository browser.