Why can't java applets run on eclipse?

Your program is missing set visible (true); Add this sentence, and add cp.add (layout.west, new jbutton(" 4));); And CP.add (layout.center, new jbutton(" 5));); You can run it by adding quotation marks. The complete process is as follows:

Import javax.swing. *;

Import java.awt. *;

The public class BorderLayout 1 extends JApplet.

{

Public void init ()

{

container CP = getContentPane();

BorderLayout layout = New Borderlayout (0,0);

Cp.add (layout. NORTH,new JButton(" 1 "));

Cp.add (layout. South, new JButton(" 2 ")););

Cp.add (layout. East, new JButton(" 3 ")););

Cp.add (layout. West, new JButton(" 4 ")););

Cp.add (layout. CENTER,new JButton(" 5 "));

set visible(true);

}

}