Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Simple Phone Applet Lab 10. 2 Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #

Similar presentations


Presentation on theme: "1 Simple Phone Applet Lab 10. 2 Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #"— Presentation transcript:

1 1 Simple Phone Applet Lab 10

2 2 Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #

3 3 Layout of Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #

4 4 You can type in the display area

5 5 You can press numbers

6 6 Panel to make Applet or Frame layout easier, we break a frame up into regions and compose each of them separately. Each region is called a Panel. Each can have its own different LayoutManager. Panels don't have any visible bounding lines. We can delimit them with differing background colours. If we want something to draw on with drawString and drawLine normally you would use a Canvas.

7 7 Button

8 8 Code of red color import java.applet.*; import java.awt.*; public class lab10 extends java.applet.Applet { public void init() { setLayout(new FlowLayout()); setBackground(Color.red); add(new Label("<<")); add(new Button("How are you DCO students")); add(new Label(">>")); }

9 9 Button of mobile phones

10 10 Source Code import java.applet.*; import java.awt.*; public class lab101 extends java.applet.Applet { public void init() { String str; setLayout(new FlowLayout()); setBackground(Color.red); add(new Button("send")); add(new Button("menu")); add(new Button("stop")); for (int i = 1; i <9; i++) { str = "" +i; //Integer to String add(new Button(str)); } add(new Button("*")); add(new Button("0")); add(new Button("#")); } }

11 11 HTML with different width Maximum Using Array

12 12 Use GridLayout String str; setLayout( new GridLayout( 5, 3 )); // row 5: col :3 setBackground(Color.red); add(new Button("send")); add(new Button("menu")); add(new Button("stop")); for (int i = 1; i <10; i++) { str = "" +i; //Integer to String add(new Button(str)); } add(new Button("*")); add(new Button("0")); add(new Button("#"));

13 13 The source code import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class Grid_JApplet1 extends JApplet { public void init() { // Swing adds JComponents to the container's // contentPane rather than directly to the panel // as with the AWT. Container contentPane = getContentPane(); // Modify and add code between this line //-------------------------------------------- // Create an instance of a JPanel sub-class GridPanel gridPanel = new GridPanel(); // And add one or more panels to the JApplet panel. contentPane.add(gridPanel); //-------------------------------------------- // and this line. } // A sample JPanel class for holding components class GridPanel extends JPanel { GridPanel() { // Modify and add code between this line //-------------------------------------------- String str; setLayout( new GridLayout( 5, 3 )); // row 5: col :3 setBackground(Color.red); add(new Button("send")); add(new Button("menu")); add(new Button("stop")); for (int i = 1; i <10; i++) { str = "" +i; //Integer to String add(new Button(str)); } add(new Button("*")); add(new Button("0")); add(new Button("#")); //-------------------------------------------- // and this line. }

14 14 The HTML

15 15 Text Field A TextField is a scrollable text display object with one row of characters. The preferred width of the field may be specified during construction and an initial string may be specified.TextField

16 16 Simple Text Field

17 17 Source Code

18 18 Source import java.awt.*; import java.applet.Applet; public class TextFieldSimpleTest extends Applet { public void init() { TextField f1 = new TextField("type something"); add(f1); }

19 19 Text Area A TextArea is a multi-row text field that displays a single string of characters, where newline ('\n' or '\n\r' or '\r', depending on platform) ends each row. The width and height of the field is set at construction, but the text can be scrolled up/down and left/right.TextArea

20 20 Text Area

21 21 Source Code import java.awt.*; import java.applet.Applet; public class TextAreaSimpleTest extends Applet { TextArea disp; public void init() { disp = new TextArea("Code goes here", 10, 30); add(disp); }

22 22 Scroll

23 23 Source code import java.awt.*; import java.applet.Applet; public class TextAreaScroll extends Applet { String s = "This is a very long message " + "How are you DCO students " + "are you learning Java?"; public void init() { add(new TextArea (s, 4, 15, TextArea.SCROLLBARS_NONE)); add(new TextArea (s, 4, 15, TextArea.SCROLLBARS_BOTH)); }

24 24 Source code of Phone

25 25 Diagram


Download ppt "1 Simple Phone Applet Lab 10. 2 Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #"

Similar presentations


Ads by Google