Java Programming tutorial, GUI, Graphical User Interface. this tutorial is teaching. How to use Java graphics for drawing, Images, for graphics interfaces and games, and using a sprite sheet to draw different sprites from that sheet.
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.*;
public class GraphicsTut extends JFrame{
Image image;
Image image2;
public GraphicsTut(){
this.setTitle("Remember g for Graphics");
this.setSize(450,350);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void paint(Graphics g){
ImageIcon i = new ImageIcon("image/Abstract-background-1.png");
image = i.getImage();
g.drawImage(image, 0, 0, null);
g.setColor(Color.BLACK);
g.drawRect(40, 40, 30, 30);
g.setColor(Color.RED);
g.drawOval(80, 80, 30, 30);
g.fillArc(140, 140, 30, 30, 180, 10);
g.drawLine(100, 300, 350, 400);
g.setFont(new Font("Arial",Font.BOLD,34));
g.drawString("Paint this!", 150, 100);
ImageIcon i2 = new ImageIcon("image/charcustomsheet.gif");
image2 = i2.getImage();
//g.drawImage(image2, 100, 200, null);
g.drawImage(image2, 100, 100, 200, 200, 40, 60, 80, 120, null);
g.drawImage(image2, 250, 250, 50, 50, null);
}
public static void main(String[] args){
new GraphicsTut();
}
}
On this page of the site you can watch the video online Java programming part 95 Graphics : Java Draw Images 4 with a duration of hours minute second in good quality, which was uploaded by the user Redemptie 03 July 2012, share the link with friends and acquaintances, this video has already been watched 7,443 times on youtube and it was liked by 32 viewers. Enjoy your viewing!