1
2
3
4
5
6
7
8
9
10
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 {
28 public <T extends JComponent> T addFixed( T component )
29 {
30 if( !( component instanceof JButton ) )
31 UISupport.setPreferredHeight( component, 18 );
32
33 Dimension preferredSize = component.getPreferredSize();
34 component.setMinimumSize( preferredSize );
35 component.setMaximumSize( preferredSize );
36
37 add( component );
38
39 return component;
40 }
41
42 public Component add( Component component )
43 {
44 if( !( component instanceof JButton ) )
45 UISupport.setPreferredHeight( component, 18 );
46
47 return super.add( component );
48 }
49
50 public void addGlue()
51 {
52 add( Box.createHorizontalGlue() );
53 }
54
55 public void addRelatedGap()
56 {
57 addSpace( 3 );
58 }
59
60 public void addUnrelatedGap()
61 {
62 addSeparator();
63 }
64
65 public void addLabeledFixed( String string, JComponent component )
66 {
67 addFixed( new JLabel( string ) );
68 addSeparator( new Dimension( 3, 3 ) );
69 addFixed( component );
70 }
71
72 public void addSpace( int i )
73 {
74 addSeparator( new Dimension( i, 1 ) );
75 }
76 }