Entry
Java: Applet: Window: Color: Background: Set: How to set the background color of an applet window?
Aug 24th, 2004 16:58
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 25 August 2004 - 01:50 am ---------------------
Java: Applet: Window: Color: Background: Set: How to set the
background color of an applet window?
Use the setBackground method, and put it in the init() method.
--- cut here ---------------------------------------------------------
// library: hello world [kn, ni, we, 25-08-2004 1:56:19]
import java.applet.*;
import java.awt.*;
//
public class HelloWorldApplet extends Applet {
//
public void init() {
setBackground( Color.blue ); // change here the applet window color
}
//
public void paint( Graphics graphics1 ) {
Font font1 = new Font( "Courier", Font.BOLD, 36 );
graphics1.setFont( font1 );
graphics1.setColor( Color.red );
graphics1.drawString( "Hello world!", 0, 30 );
}
}
--- cut here ---------------------------------------------------------
----------------------------------------------------------------------