This is my assignment guys and i have some serius problems here..
I have to make a phonepad and i managed to make only the number
buttons but there are some other buttons that it impossible for me
to make them work..
These are the additional buttons that i have to add to the program bellow
but i can not manage to make them.
• A button labeled 'C' used to delete the latest digit entered
• A display showing the keyed-in number (which grows digit by digit as the user keys the number in)
• A button labeled "Dial" used to initiate a call
• A button labeled "Hang up" used to terminate the call
• An updating display monitoring the time taken for the call
If someone have any idea help me please...its urgent...
Thanx a lot...
CODE
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PhonePad implements ActionListener {
private JFrame frame;
private JPanel panel;
private JTextField textField;
public PhonePad() {
}
public void createWindow() {
System.out.println("Initializing Window");
frame = new JFrame("London Telepad");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
panel = new JPanel();
panel.setLayout(new GridLayout(4, 3));
JButton butt1 = new JButton("1");
JButton butt2 = new JButton("2");
JButton butt3 = new JButton("3");
JButton butt4 = new JButton("4");
JButton butt5 = new JButton("5");
JButton butt6 = new JButton("6");
JButton butt7 = new JButton("7");
JButton butt8 = new JButton("8");
JButton butt9 = new JButton("9" );
JButton buttstar = new JButton("*");
JButton butt0 = new JButton("0");
JButton butthash = new JButton("#");
buttc.addActionListener(this);
butt0.addActionListener(this);
butt1.addActionListener(this);
butt7.addActionListener(this);
butt8.addActionListener(this);
panel.add(butt1);
panel.add(butt2);
panel.add(butt3);
panel.add(butt4);
panel.add(butt5);
panel.add(butt6);
panel.add(butt7);
panel.add(butt8);
panel.add(butt9);
panel.add(buttstar);
panel.add(butt0);
panel.add(butthash);
frame.getContentPane().add(panel);
frame.setSize(200, 300);
frame.setVisible(true);
System.out.println("Window Initialized");
}
// method needed for testing with Robot class
public JFrame getFrame() {
return frame;
}
public static void main(String args[]) {
PhonePad app = new PhonePad();
app.createWindow();
}
public void actionPerformed(ActionEvent e) {
// Display text of button on shell window
System.out.print(e.getActionCommand());
}
}