What is a graphical context (in Java)?

I have seen this term several times, what does it mean?

+5
source share
4 answers

"Context" is the common name that many java developers use for classes that contain state information. Therefore, we should see many different class names containing context.

The graphical context on the Java desktop usually means java.awt.Graphics or java.awt.Graphics2D . They carry information about drawing properties: colors, line properties, clipping areas, etc.

+7
source

, SWING/AWT.

:

class JMyComponent extends JComponent
{
    @Override
    public void paint(Graphics g) {  
        // g contains graphics context
        g.fillOval(...);  // draw an oval on the component
        // more graphics primitives...
    }
}

. Java -Java.

+4

Graphics - Graphics, Java

http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html

AWT Swing paint (Graphics g) . Graphics ( ) , .

+1

To make any drawing in Java, you need a graphics context. A graphics context is an object that belongs to the java.awt.Graphics class.

http://www.faqs.org/docs/javap/c6/s3.html

0
source

All Articles