Java Programming tutorial, GUI, Graphical User Interface. this tutorial is teaching. How to use Java graphics for drawing, Images, for graphics interfaces and games,Showing you how to manipulate the image, by making the image face in the opposite direction, and sit upside down ect.
// GraphicsTut.java classbelow and below that BGround.java class
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;
int x1,y1,x2,y2;
BKGround bkg = new BKGround();
public GraphicsTut(){
this.setTitle("Remember g for Graphics");
this.setSize(450,350);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.add(bkg);
}
public void paint(Graphics g){
}
public static void main(String[] args){
new GraphicsTut();
}
}
// below BKGround.java class
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
public class BKGround extends JPanel{
Image image;
Image image2;
int x1,y1,x2,y2;
public BKGround(){
ImageIcon I = new ImageIcon("image/Abstract-background-1.png");
image = I.getImage();
ImageIcon I2 = new ImageIcon("image/madBoySprite.png");
image2 = I2.getImage();;
}
public void paint(Graphics g){
x1 = 200;
y1 = 200;
x2 = 100;
y2 = 100;
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, x1, y1, x2, y2, 40, 60, 80, 120,Color.GREEN, null);
g.drawImage(image2, 250, 250, 50, 50, null);
repaint();
}
}
On this page of the site you can watch the video online Java programming part 97 Graphics : Java Image Manipulation 5 with a duration of hours minute second in good quality, which was uploaded by the user Redemptie 07 July 2012, share the link with friends and acquaintances, this video has already been watched 4,059 times on youtube and it was liked by 7 viewers. Enjoy your viewing!