Example usage for java.awt Graphics finalize

List of usage examples for java.awt Graphics finalize

Introduction

In this page you can find the example usage for java.awt Graphics finalize.

Prototype

@Deprecated(since = "9")
public void finalize() 

Source Link

Document

Disposes of this graphics context once it is no longer referenced.

Usage

From source file:Main.java

public void paint(Graphics g) {
    g.setColor(Color.red);//from w  w w  . j  ava  2  s  .c o m
    Graphics clippedGraphics = g.create();
    clippedGraphics.drawRect(0, 0, 100, 100);
    clippedGraphics.clipRect(25, 25, 50, 50);
    clippedGraphics.drawLine(0, 0, 100, 100);
    clippedGraphics.finalize();
    clippedGraphics = null;
    g.drawLine(0, 100, 100, 0);
}