Help! I'm making a graphical user interface and here's the first version of my code:
But the problem is, it only shows the two buttons "beta" and "sigma". I want all the AWT elements to be displayed on the screen. What should I do?Code:import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class MainProgram
{
Frame phi;
Button beta, sigma;
Choice tau;
TextField alpha1, alpha2, alpha3, nu;
Panel pi, pi2;
public static void main (String args[]) throws IOException
{
MainProgram main = new MainProgram();
main.addComponents();
}
public MainProgram()
{
phi = new Frame("MKDL Travel Agency System v1.0");
}
public void addComponents()
{
File data = new File ("report.txt");
int q = 0;
TravellingPackage prog[] = new TravellingPackage[10];
phi = new Frame("MKDL Travel Agency System v1.0");
beta = new Button("Calculate Fare");
sigma = new Button("Save Data");
tau = new Choice();
alpha1 = new TextField("Below 2",2);
alpha2 = new TextField("2-16",2);
alpha3 = new TextField("Above 16",2);
nu = new TextField("Agent Name",50);
pi = new Panel();
pi2 = new Panel();
phi.setSize(512,384);
phi.setBackground(Color.gray);
tau.add("Bus");
tau.add("Cruise");
tau.add("Airplane");
pi.add(tau);
pi.add(alpha1);
pi.add(alpha2);
pi.add(alpha3);
pi.add(nu);
pi2.add(beta);
pi2.add(sigma);
phi.add(pi);
phi.add(pi2);
phi.pack();
phi.setVisible(true);
}
}