01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.support.components;
14:
15: import java.awt.Component;
16: import java.awt.Dimension;
17:
18: import javax.swing.Box;
19: import javax.swing.JButton;
20: import javax.swing.JComponent;
21: import javax.swing.JLabel;
22: import javax.swing.JToolBar;
23:
24: import com.eviware.soapui.support.UISupport;
25:
26: public class JXToolBar extends JToolBar {
27: public void addFixed(JComponent component) {
28: if (!(component instanceof JButton))
29: UISupport.setPreferredHeight(component, 18);
30:
31: Dimension preferredSize = component.getPreferredSize();
32: component.setMinimumSize(preferredSize);
33: component.setMaximumSize(preferredSize);
34:
35: add(component);
36: }
37:
38: public Component add(Component component) {
39: if (!(component instanceof JButton))
40: UISupport.setPreferredHeight(component, 18);
41:
42: return super .add(component);
43: }
44:
45: public void addGlue() {
46: add(Box.createHorizontalGlue());
47: }
48:
49: public void addRelatedGap() {
50: addSpace(3);
51: }
52:
53: public void addUnrelatedGap() {
54: addSeparator();
55: }
56:
57: public void addLabeledFixed(String string, JComponent component) {
58: addFixed(new JLabel(string));
59: addSeparator(new Dimension(3, 3));
60: addFixed(component);
61: }
62:
63: public void addSpace(int i) {
64: addSeparator(new Dimension(i, 1));
65: }
66: }
|