IT. Expert System.

Java basics

getGraphics()


Creates a graphics context for this component. This method will return null if this component is currently not displayable.a graphics context for this component, or null if it has none

Syntax:
public Graphics getGraphics()


Example:

import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class GetGraphics_Image {
  public static void main(String[] args) {
    Frame frame = new Frame("GetGraphics_Image");
    frame.setSize(800, 800);
    frame.add(new CanvasToDisplay());
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
  }
}

class CanvasToDisplay extends Component {
  public void paint(Graphics g) {

    // This call returns immediately and pixels are loaded in the background
    Image image = Toolkit.getDefaultToolkit().getImage("C:\\leaderboard.gif");
    image.flush();
    image.getAccelerationPriority();
    image.getCapabilities(getGraphicsConfiguration());
//    image.getGraphics();
    int height = image.getHeight(null);
//    image.getProperty(getName(), getParent());
    image.getScaledInstance(10,20,100);
    image.getSource();
    int width = image.getWidth(null);
    image.setAccelerationPriority(0.4f);
    g.drawImage(image, width, height, this);
  }
}


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 976 / 159176084. Delta: 0.00306 с