When I run the following program, the applet window displays nothing. I will be grateful for any help.

import javax.swing.*;
import java.awt.*;

public class BoxPanel extends JPanel
   private JTextField label1, label2;
   public BoxPanel()
         setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
         label1 = new JTextField(20);
         label2 = new JTextField(20);
import javax.swing.*;
import java.awt.*;
public class App extends JApplet
    private JLabel label1, label2;
    private BoxPanel panelA, panelB;
    public void init()
        panelA = new BoxPanel();
        Container c = getContentPane();

Thank you!

I can't see anywhere that you have constructed any frame or panel in which to add to the frame to then set it frame visible, you can also use a Container...


JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

I would suggest you look at the BoxLayout or JFrames/Panels tutorials so you can see how a basic class is put together as a whole. Oracle uses a container or you can construct a frame and panel to then add the panel to it. Links provided below:

Box Layout Examplehttp://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BoxLayoutDemoProject/src/layout/BoxLayoutDemo.java

Box Layouts http://docs.oracle.com/javase/tutorial/uiswing/layout/box.html

Panels http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html#creating

Frames: http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html

I would also make the lables public as you want to use them in a public method.

Hope that helps

It works for me. I see a vertical dividing line between the two JTextFields.

Try typing something into the text fields.
Try putting a String into them in the constructor.