// Phone.java
// Creates the cell phone GUI.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class Phone extends JFrame
{
private JLabel displayJLabel;
private JPanel numberJPanel;
private JButton oneJButton, twoJButton, threeJButton,
fourJButton, fiveJButton, sixJButton, sevenJButton,
eightJButton, nineJButton, starJButton, zeroJButton,
poundJButton, talkJButton, endJButton;
// no-argument constructor
public Phone()
{
createUserInterface();
}
// create and position GUI components
private void createUserInterface()
{
// get content pane and set its layout
Container contentPane = getContentPane();
contentPane.setLayout( null );
// set up displayJLabel
displayJLabel = new JLabel();
displayJLabel.setText( "Deitel Wireless" );
displayJLabel.setBounds( 10, 10, 170, 100 );
displayJLabel.setBorder( new LineBorder( Color.BLACK ) );
displayJLabel.setHorizontalAlignment( JLabel.CENTER );
displayJLabel.setBackground( Color.CYAN );
displayJLabel.setOpaque( true );
contentPane.add( displayJLabel );
// set up talkJButton
talkJButton = new JButton();
talkJButton.setText( "TALK" );
talkJButton.setBounds( 10, 120, 80, 30 );
contentPane.add( talkJButton );
// set up endJButton
endJButton = new JButton();
endJButton.setText( "END" );
endJButton.setBounds( 100, 120, 80, 30 );
contentPane.add( endJButton );
// set up numberJPanel
numberJPanel = new JPanel();
numberJPanel.setBounds( 10, 160, 60, 110 );
numberJPanel.setBorder( new LineBorder( Color.BLACK ) );
numberJPanel.setLayout( null );
contentPane.add( numberJPanel );