This is my first time posting here.
I am using GUI in java for the very first time while working on some homework. I have started incrementally coding a Italian restaurant menu.
The below code is compiling fine with no errors. After compiling I run applet viewer Italian.html and the applet viewer screen only displays a blank window. I am a little confused as I have no errors to work with. Am I missing something simple.
Thanks for any help.
import javax.swing.*;
import java.awt.*;
public class Italian extends JApplet {
//Declare and array for a list of Pastas
private String [] pastas = {"Spaghetti", "Angel Hair Pasta", "Tortellini",
"Ziti"};
private String [] sauces = {"Maranaria", "Alfredo", "Spicy Marania"};
public Italian() {
//Create the base panel for the restaurant page
JPanel i1 = new JPanel();
i1.setLayout(new GridLayout(2, 1));
i1.add(new JComboBox(pastas));
i1.add(new JComboBox(sauces));
HTML
<html>
<head>
<title>Java Applet Demo</title>
</head>
<body>
<applet
code = "Italian.class"
width = 250
height = 250>
</applet>
</body>
</html>
You haven’t added anything to the applet for the applet to show on the screen.
Either in your constructor or you init method you need to add the panel you’ve created to the content pane.