java - Image not displaying in simple applet -


I am working with Java images for the first time and when the applet loads, they are having trouble viewing it. The code I have posted below is actually a dramatically down-down version of the code, hopefully I do not see an image with this code, will show me as long as I have to resize the window All help of picture is greatly appreciated and thanks is extended in advance :)

  import java.applet. *; Import java.awt. *; Import java.awt.event. *; Import java.awt.image. *; Import javax.swing *; Import java.util. *; Import java.awt.Graphics; Examples of public class implement japplets runanble {boolean update; Thread thread; Private mill width, height; Test image drawboard; // Used for creating and storing values ​​Private audio clip [] Sound = New audio clip [4]; // private key counter to capture the array audio clip = 0; // counter private image game image for audio clip array; Personal Graphics Game Graphics; Public Example () // Up Uplet Guinea {this.resize (new dimension (600, 500)); // Setup table // aTable = new table (50, 50, 50, 50, 16, 16, get image ("picture / FLY.gif", color. White), //getImage(_images/FlySwatter.gif " White color)) // should be a square of the table or move the flaswaator, directly to a table = new test image draw (IIMAG ("Images / FLY.gif", Color. White)); //this.add (ATable); SuperRessage (800, 600); Re-coloring ();} Public Zero Init () {width = getSize (). Width; height = getSize (); height; GameImage = createImage (width, height) ; GameGraphics = GameGadgetgateGrof X (); // Automatic in some systems; others do not include GameGraphics.setColor (Color.black); Repaint (); Valid ();} Public Zero Start () {thread = new thread (this); thread Start ();} public zero-stop () {updating = false;} public run zero () {while (updated) {//aTable.update ();} ATable.revalidate ();} // gives a transparent image // Color has got a transparent private image image (string imgpath, last color color) {image img = Toolkit.getDefaultToolkit (.) GetImage (imgPath); ImageFilter filter = New RGBMff Filter () {// The colors we are looking for ... Alpha Bits are set to opaque public int mark marker RGB = color. RARGb () | 0xFFFFFF; Public Ultimate Favored Filter RGB (int x, int y, int rgb) {if ((rgb | 0xFF000000) == markerRGB) {// Mark alpha bits as zero - Transparent return 0x00FFFFFF & amp; RGB; } Else {// nothing returns to RGB; }}}; ImageProducer ip = New filtered image source (img.getSource (), filter); Img = Toolkit.getDefaultToolkit (). CreateImage (IP); Return img; }}  

TestImageDraw.java

  import java.awt. *; Import java.util.Random; Import javax.swing *; Public Class Test Image Draws Expansion Jpnell (Image Image; / / Item Image Public Public Examination Image Draw (Image Item Img) stores {this.itemImg = itemImg;} / ** Description of Draw (Graphics G) * The function draws the lines used in the table * @param g is used to draw the table * @ layer not * / public zero draw (graphics g) {Graphics2D g2 = (Graphics2D) g; // Draw f Asustar Draw Value (G2); // Draw Value} Private Zero Cost (Graphics G) {g.drawImage (itemImg, 20,140,30,40, blank); g.setColor (Color.black); // set Color color black}}  

This is not a simple example, still a lot in code For example, do all image filtering with displaying a picture, for example? What does all the thread code do with displaying an image?

I have an hour ago With taught the basics of painting, then I have one thing I did not hear.

I taught you all about the paint coment () I told you about the swing tutorial, in which there is a work example of using an image. Nothing looks like an example in the structure tutorial of your applet. Your example would be very simple because you do not have to worry about animation.

Not only did you waste your time yesterday, but you know that you are trying to ruin other people.

Learn from the tutorial and post the appropriate SSCCE.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -