Fonts and Graphics
Flicker Free Graphics, .GIF and .JPEG Display - Con't
Java makes it very easy to use graphics in JPEG and GIF format, even GIFs with transparency index, so it is no problem to display sprites for a game. The duck in this applet uses a transparent background color, the rose is a JPEG. For pictures with a large color palette (photos) you should always take JPEGs, for graphics that don't need many colors or need to be very sharp, you should prefer GIFs.
|
//Sourcecode
import java.awt.*;
import java.applet.*;
//you can easily load and display graphics in GIF and JPEG format
//GIFs with transparent colors are also supported!
public class Project10 extends Applet
{
Image pic1, pic2, pic3;
public void init()
{
pic1=getImage(getCodeBase(),"rose.jpg");
pic2=getImage(getCodeBase(),"boat.gif");
pic3=getImage(getCodeBase(),"duck.gif");
}
public void paint (Graphics g)
{
g.drawImage(pic1, 90,10,this);
g.drawImage(pic2, 30,70,this);
g.drawImage(pic3, 140,130,this);
}
}
|
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.