Module ij
Package ij.gui

# Class GUI

java.lang.Object
ij.gui.GUI

public class GUI extends Object
This class consists of static GUI utility methods.

## Constructor Summary

Constructors
Constructor
Description
`GUI()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`center(Window win)`
`static void`
`center(Window win, Component target)`
Positions the specified window in the center of the screen that contains target.
`static void`
`centerOnImageJScreen(Window win)`
Positions the specified window in the center of the screen containing the "ImageJ" window.
`static Image`
`createBlankImage(int width, int height)`
Obsolete
`static void`
`fix(Scrollbar sb)`
Lightens overly dark scrollbar background on Windows 8.
`static final void`
`fixScrollbar(Scrollbar sb)`
Works around an OpenJDK bug on Windows that causes the scrollbar thumb color and background color to be almost identical.
`static Rectangle`
`getMaxWindowBounds()`
`static Rectangle`
`getMaxWindowBounds(Component component)`
`static Rectangle`
`getMaxWindowBounds(Point point)`
`static Rectangle`
`getScreenBounds()`
`static Rectangle`
`getScreenBounds(Component component)`
`static Rectangle`
`getScreenBounds(Component component, boolean accountForInsets)`
Get maximum bounds for the screen that contains a given component.
`static Rectangle`
`getScreenBounds(Point point)`
`static Rectangle`
`getScreenBounds(Point point, boolean accountForInsets)`
Get maximum bounds for the screen that contains a given point.
`static Rectangle`
`getUnionOfBounds()`
`static Rectangle`
`getZeroBasedMaxBounds()`
`static GenericDialog`
`newNonBlockingDialog(String title)`
Returns a new NonBlockingGenericDialog with the given title, except when Java is running in headless mode, in which case a GenericDialog is be returned.
`static GenericDialog`
`newNonBlockingDialog(String title, ImagePlus imp)`
Returns a new NonBlockingGenericDialog with the given title if Prefs.nonBlockingFilterDialogs is 'true' and 'imp' is displayed, otherwise returns a GenericDialog.
`static void`
`scale(Component component)`
Scales an AWT component according to `Prefs.getGuiScale()`.
`static boolean`
`scale(JComponent component)`
Tries to detect if a Swing component is unscaled and scales it it according to
invalid reference

    #getGuiScale()

.
`static void`
`scalePopupMenu(PopupMenu popup)`
`static boolean`
`showCompositeAdvisory(ImagePlus imp, String title)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### GUI

public GUI()

## Method Details

### center

public static void center(Window win, Component target)
Positions the specified window in the center of the screen that contains target.

### centerOnImageJScreen

public static void centerOnImageJScreen(Window win)
Positions the specified window in the center of the screen containing the "ImageJ" window.

### center

public static void center(Window win)

### getScreenBounds

public static Rectangle getScreenBounds(Point point, boolean accountForInsets)
Get maximum bounds for the screen that contains a given point.

Parameters:
  `point` - Coordinates of point.
  `accountForInsets` - Deduct the space taken up by menu and status bars, etc. (after point is found to be inside bonds)
Returns:
  Rectangle of bounds or `null` if point not inside of any screen.

### getScreenBounds

public static Rectangle getScreenBounds(Component component, boolean accountForInsets)
Get maximum bounds for the screen that contains a given component.

Parameters:
  `component` - An AWT component located on the desired screen. If `null` is provided, the default screen is used.
  `accountForInsets` - Deduct the space taken up by menu and status bars, etc.
Returns:
  Rectangle of bounds.

### getScreenBounds

public static Rectangle getScreenBounds(Point point)

### getScreenBounds

public static Rectangle getScreenBounds(Component component)

### getScreenBounds

public static Rectangle getScreenBounds()

### getMaxWindowBounds

public static Rectangle getMaxWindowBounds(Point point)

### getMaxWindowBounds

public static Rectangle getMaxWindowBounds(Component component)

### getMaxWindowBounds

public static Rectangle getMaxWindowBounds()

### getZeroBasedMaxBounds

public static Rectangle getZeroBasedMaxBounds()

### getUnionOfBounds

public static Rectangle getUnionOfBounds()

### createBlankImage

public static Image createBlankImage(int width, int height)
Obsolete

### fix

public static void fix(Scrollbar sb)
Lightens overly dark scrollbar background on Windows 8.

### showCompositeAdvisory

public static boolean showCompositeAdvisory(ImagePlus imp, String title)

### scale

public static void scale(Component component)
Scales an AWT component according to `Prefs.getGuiScale()`.

Parameters:
  `component` - the AWT component to be scaled. If a container, scaling is applied to all its child components

### scalePopupMenu

public static void scalePopupMenu(PopupMenu popup)

### scale

public static boolean scale(JComponent component)
Tries to detect if a Swing component is unscaled and scales it it according to
invalid reference

    #getGuiScale()

.

This is mainly relevant to linux: Swing components scale automatically on most platforms, specially since Java 8. However there are still exceptions to this on linux: e.g., In Ubuntu, Swing components do scale, but only under the GTK Linvalid input: '&F'. (On the other hand AWT components do not scale at all on hiDPI screens on linux).

This method tries to avoid exaggerated font sizes by detecting if a component has been already scaled by the UIManager, applying only

invalid reference

    #getGuiScale()

to the component's font if not.

Parameters:
  `component` - the component to be scaled
Returns:
  true, if component's font was resized

### fixScrollbar

public static final void fixScrollbar(Scrollbar sb)
Works around an OpenJDK bug on Windows that causes the scrollbar thumb color and background color to be almost identical.

### newNonBlockingDialog

public static GenericDialog newNonBlockingDialog(String title)
Returns a new NonBlockingGenericDialog with the given title, except when Java is running in headless mode, in which case a GenericDialog is be returned.

### newNonBlockingDialog

public static GenericDialog newNonBlockingDialog(String title, ImagePlus imp)
Returns a new NonBlockingGenericDialog with the given title if Prefs.nonBlockingFilterDialogs is 'true' and 'imp' is displayed, otherwise returns a GenericDialog.

Parameters:
  `title` - Dialog title
  `imp` - The image associated with this dialog