My applet which is supposed to display a Telephone Keypad wont display anyting
Here is the Code, PLease Help
The class:
The Driver Program:
Here is the Code, PLease Help
The class:
Code:
//******************************************************
// TelephonePanel.java
//
// Lays out a (functionless) GUI like a telephone keypad with a title.
// Illustrates use of BorderLayout and GridLayout.
//******************************************************
import java.awt.*;
import javax.swing.*;
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
public class TelephonePanel extends JPanel
{
private JLabel label;
public TelephonePanel()
{
//set BorderLayout for this panel
JPanel p = new JPanel(new BorderLayout());
//create a JLabel with "Your Telephone" title
label = new JLabel ("Your Telephone");
//add title label to north of this panel
p.add(label, BorderLayout.NORTH);
//create panel to hold keypad and give it a 4x3 GridLayout
JPanel keys = new JPanel(new GridLayout(3,4));
//add buttons representing keys to key panel
keys.add(new JButton("9"));
keys.add(new JButton("8"));
keys.add(new JButton("7"));
keys.add(new JButton("6"));
keys.add(new JButton("5"));
keys.add(new JButton("4"));
keys.add(new JButton("3"));
keys.add(new JButton("2"));
keys.add(new JButton("1"));
keys.add(new JButton("#"));
keys.add(new JButton("0"));
keys.add(new JButton("*"));
//add key panel to center of this panel
p.add(keys, BorderLayout.CENTER);
}
}
Code:
//******************************************************
// Telephone.java
//
// Uses the TelephonePanel class to create a (functionless) GUI
// like a telephone keypad with a title.
// Illustrates use of BorderLayout and GridLayout.
//******************************************************
import javax.swing.*;
public class Telephone
{
public static void main(String[] args)
{
JFrame frame = new JFrame("Telephone");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new TelephonePanel());
frame.pack();
frame.setVisible(true);
}
}
Comment