View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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  {
28  	public void addFixed( JComponent 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  
40  	public Component add(Component component)
41  	{
42  		if( !(component instanceof JButton) )
43  			UISupport.setPreferredHeight( component, 18 );
44  
45  		return super.add(component);
46  	}
47  
48  	public void addGlue()
49  	{
50  		add( Box.createHorizontalGlue() );
51  	}
52  
53  	public void addRelatedGap()
54  	{
55  		addSpace( 3 );
56  	}
57  
58  	public void addUnrelatedGap()
59  	{
60  		addSeparator();
61  	}
62  
63  	public void addLabeledFixed(String string, JComponent component)
64  	{
65  		addFixed( new JLabel( string ));
66  		addSeparator( new Dimension( 3, 3 ));
67  		addFixed( component );
68  	}
69  
70  	public void addSpace(int i)
71  	{
72  		addSeparator( new Dimension( i, 1 ));
73  	}
74  }