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

Last change on this file since 5357 was 5166, checked in by jmt12, 21 years ago

A button which has an image at both the left and right

  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1package org.greenstone.gatherer.gui;
2
3import java.awt.*;
4import javax.swing.*;
5
6/** A button that allows for an icon at both the left and right sides. */
7public class DoubleImageButton
8 extends JButton {
9
10 static final private Dimension SIZE = new Dimension(160, 25);
11
12 private JLabel west_disabled_icon_label;
13 private JLabel east_disabled_icon_label;
14 private JLabel west_enabled_icon_label;
15 private JLabel east_enabled_icon_label;
16
17 public DoubleImageButton(String title, ImageIcon enabled_icon, ImageIcon disabled_icon) {
18 super(title);
19
20 setPreferredSize(SIZE);
21
22 west_disabled_icon_label = new JLabel(disabled_icon);
23 east_disabled_icon_label = new JLabel(disabled_icon);
24 west_enabled_icon_label = new JLabel(enabled_icon);
25 east_enabled_icon_label = new JLabel(enabled_icon);
26
27 setEnabled(false);
28 setLayout(new BorderLayout());
29 add(west_disabled_icon_label, BorderLayout.WEST);
30 add(west_disabled_icon_label, BorderLayout.EAST);
31 }
32
33 public void setEnabled(boolean enabled) {
34 super.setEnabled(enabled);
35 if(enabled) {
36 remove(west_disabled_icon_label);
37 remove(east_disabled_icon_label);
38 add(west_enabled_icon_label, BorderLayout.WEST);
39 add(east_enabled_icon_label, BorderLayout.EAST);
40 }
41 else {
42 remove(west_enabled_icon_label);
43 remove(east_enabled_icon_label);
44 add(west_disabled_icon_label, BorderLayout.WEST);
45 add(east_disabled_icon_label, BorderLayout.EAST);
46 }
47 validate();
48 }
49}
Note: See TracBrowser for help on using the repository browser.