Example usage for javax.swing JSeparator setSize

List of usage examples for javax.swing JSeparator setSize

Introduction

In this page you can find the example usage for javax.swing JSeparator setSize.

Prototype

public void setSize(Dimension d) 

Source Link

Document

Resizes this component so that it has width d.width and height d.height .

Usage

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/** 
 * Create a separator to add to a toolbar. The separator needs to be 
 * set when the layout of the toolbar is reset.
 * /*from  ww  w.j a  v a2 s  . c  o  m*/
 * @param button   The button to add to the toolBar. The height of the 
 *                separator depends of the insets of the button.
 * @param icon     The icon to add to the button. The height of the 
  *                 separator depends of the height of the icon.
 * @return See below.
 */
public static JSeparator toolBarSeparator(JButton button, Icon icon) {
    JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
    if (button == null)
        return separator;
    Insets i = button.getInsets();
    int h = 0;
    if (icon != null)
        h = icon.getIconHeight();
    Dimension d = new Dimension(SEPARATOR_WIDTH, i.top + h + i.bottom);
    separator.setPreferredSize(d);
    separator.setSize(d);
    return separator;
}