Java Utililty Methods Graphics Settings

List of utility methods to do Graphics Settings

Description

The list of methods to do Graphics Settings are organized into topic(s).

Method

GraphicsConfigurationgetDefaultConfig()
get Default Config
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
GraphicsConfigurationgetDefaultConfiguration()
get Default Configuration
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.getDefaultConfiguration();
GraphicsConfigurationgetDefaultGraphicsConfiguration()
get Default Graphics Configuration
try {
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (!env.isHeadlessInstance()) {
        return env.getDefaultScreenDevice().getDefaultConfiguration();
} catch (LinkageError e) {
    VM_SUPPORTS_ACCELERATION = false;
return null;
GraphicsConfigurationgetDefaultGraphicsConfiguration()
Return the default graphics configuration.
try {
    return getDefaultScreenDevice().getDefaultConfiguration();
} catch (Exception e) {
    return null;
java.awt.GraphicsConfigurationgetDefaultGraphicsConfiguration()
get Default Graphics Configuration
java.awt.GraphicsEnvironment ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
java.awt.GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.getDefaultConfiguration();
RectanglegetMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets)
Returns maximum window bounds for the specified graphics configuration.
if (gc != null) {
    final Rectangle b = gc.getBounds();
    if (applyScreenInsets) {
        final Insets si = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        return new Rectangle(si.left, si.top, b.width - si.left - si.right, b.height - si.top - si.bottom);
    } else {
        return new Rectangle(0, 0, b.width, b.height);
} else {
    return GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
MapgetRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints)
Returns map with rendering hints from a Graphics instance.
if (savedHints == null) {
    savedHints = new RenderingHints(null);
} else {
    savedHints.clear();
if (hintsToSave == null || hintsToSave.size() == 0) {
    return savedHints;
final Set objects = hintsToSave.keySet();
for (final Object o : objects) {
    final RenderingHints.Key key = (RenderingHints.Key) o;
    final Object value = g2d.getRenderingHint(key);
    if (value != null) {
        savedHints.put(key, value);
return savedHints;
RenderingHintsgetRenderingHints(Graphics2D g2d, Map hintsToSave, RenderingHints savedHints)
Get rendering hints from a Graphics instance.
if (savedHints == null)
    savedHints = new RenderingHints(null);
else
    savedHints.clear();
if (hintsToSave.isEmpty())
    return savedHints;
for (Object o : hintsToSave.keySet()) {
    RenderingHints.Key key = (RenderingHints.Key) o;
...
RenderingHintsgetRenderingHints(Graphics2D g2d, RenderingHints hintsToSave, RenderingHints savedHints)
Get rendering hints from a Graphics instance.
if (savedHints == null) {
    savedHints = new RenderingHints(null);
} else {
    savedHints.clear();
if (hintsToSave == null || hintsToSave.size() == 0) {
    return savedHints;
Set objects = hintsToSave.keySet();
for (Object o : objects) {
    RenderingHints.Key key = (RenderingHints.Key) o;
    Object value = g2d.getRenderingHint(key);
    savedHints.put(key, value);
return savedHints;
GraphicsConfigurationgetSecondWindowConfiguration()
get Second Window Configuration
GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
if (screens.length < 2) {
    return null;
return screens[1].getDefaultConfiguration();