Java applet does not display anything

前端 未结 5 690
无人及你
无人及你 2021-01-19 03:06

Does anyone know why my Java applet does not display anything?

This is my first Java applet so I am new to creating one. I researched this problem and haven\'t found

5条回答
  •  广开言路
    2021-01-19 03:49

    Here is a screenshot of this working code. Except shortened from the applet height specified.

    JavaRocksApplet

    So, as Neet noted in a comment. 'It works here.'

    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Font;
    import java.awt.Color;
    
    /*
     
    */
    public class JavaRocksApplet extends Applet
    {
        public void paint( Graphics screen )
        {
            Font f = new Font( "TimesRoman", Font.ITALIC, 36 );
            screen.setFont( f );
            Color c = new Color( 40, 80, 120 );
            screen.setColor( c );
            screen.drawString( "Java Rocks!!", 100, 60 );
        }
    }
    

    Likely more details on the actual cause of the problem can be found by viewing the console. See How do I enable and view the Java Console?

提交回复
热议问题