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.AbstractButton;
19 import javax.swing.Box;
20 import javax.swing.JButton;
21 import javax.swing.JComponent;
22 import javax.swing.JLabel;
23 import javax.swing.JToolBar;
24
25 import com.eviware.soapui.support.UISupport;
26
27 public class JXToolBar extends JToolBar
28 {
29 public <T extends JComponent> T addFixed( T component )
30 {
31 if( !( component instanceof JButton ) )
32 UISupport.setPreferredHeight( component, 18 );
33
34 Dimension preferredSize = component.getPreferredSize();
35 component.setMinimumSize( preferredSize );
36 component.setMaximumSize( preferredSize );
37
38 add( component );
39
40 return component;
41 }
42
43 public Component add( Component component )
44 {
45 if( !( component instanceof AbstractButton ) )
46 UISupport.setPreferredHeight( component, 18 );
47
48 return super.add( component );
49 }
50
51 public void addGlue()
52 {
53 add( Box.createHorizontalGlue() );
54 }
55
56 public void addRelatedGap()
57 {
58 addSpace( 3 );
59 }
60
61 public void addUnrelatedGap()
62 {
63 addSeparator();
64 }
65
66 public void addLabeledFixed( String string, JComponent component )
67 {
68 addFixed( new JLabel( string ) );
69 addSeparator( new Dimension( 3, 3 ) );
70 addFixed( component );
71 }
72
73 public void addSpace( int i )
74 {
75 addSeparator( new Dimension( i, 1 ) );
76 }
77 }