Here is the main point is to draw pictures, so-called drawing pictures, is the external picture information loaded into memory and then by the Java compiler to draw, generally feel compared to B/s development some trouble, not to say the principle of trouble, their principles are actually the same, not the same is the complexity of their implementation process, to rewrite the method , loading pictures, displaying pictures, etc. However, there is a certain significance, there is a point to note that is the path of loading, must not load errors, responsible for the memory of a large problem.
Package Huitu;import Java.awt.*;import javax.swing.*;p ublic class H1 extends jframe{/** * @param args */public static void Main (string[] args) {H1 c1= new H1 (); Mypanel mp=null;public H1 () {Mypanel mp=new mypanel (); This.add (MP); This.setsize (400,300); this.setvisible (True);}} Class Mypanel extends jpanel{//override JPanel method public void Paint (Graphics g) {//Call parent class to complete initialization super.paint (g);//Get Picture image im= Toolkit.getdefaulttoolkit (). GetImage (Panel.class.getResource ("/duanwu.jpg")); G.drawimage (IM, +, +, );}}
Java drawing-Drawing pictures