TelephonePanel - this.add(titlePanel BorderLayout.NORTH/create panel to hold keypad and give it a 4x3 GridLayout JPanel keys = new JPanel

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//****************************************************** // // // Lays out a (functionless) GUI like a telephone keypad with a title. // Illustrates use of BorderLayout and GridLayout. //****************************************************** import java.awt.*; import javax.swing.*; public class TelephonePanel extends JPanel { public TelephonePanel() { //set BorderLayout for this panel this.setLayout(new BorderLayout()); //create a JLabel with "Your Telephone" title JLabel title = new JLabel("Your Telephone!!"); //create panel to hold label; add label to panel JPanel titlePanel = new JPanel(); titlePanel.add(title); //add title panel to north of this panel
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: this.add(titlePanel, BorderLayout.NORTH); //create panel to hold keypad and give it a 4x3 GridLayout JPanel keys = new JPanel(); keys.setLayout(new GridLayout(4,3)); //add buttons representing keys to key panel keys.add(new JButton("1")); keys.add(new JButton("2")); keys.add(new JButton("3")); keys.add(new JButton("4")); keys.add(new JButton("5")); keys.add(new JButton("6")); keys.add(new JButton("7")); keys.add(new JButton("8")); keys.add(new JButton("9")); keys.add(new JButton("*")); keys.add(new JButton("0")); keys.add(new JButton("#")); //add key panel to center of this panel this.add(keys, BorderLayout.CENTER); } }...
View Full Document

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Ask a homework question - tutors are online