JText Area Constructors F JText Areaint rows int

  • Slides: 20
Download presentation
JText. Area Constructors F JText. Area(int rows, int columns) Creates a text area with

JText. Area Constructors F JText. Area(int rows, int columns) Creates a text area with the specified number of rows and columns. F JText. Area(String s, int rows, int columns) Creates a text area with the initial text and the number of rows and columns specified. Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 1

JText. Area Properties F text F editable F columns F line. Wrap F wrap.

JText. Area Properties F text F editable F columns F line. Wrap F wrap. Style. Word F rows F line. Count F tab. Size Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 2

Check. Box F ����������� on-off ��������� off F ���� check box ������� JCheck. Box

Check. Box F ����������� on-off ��������� off F ���� check box ������� JCheck. Box ch = new JCheck. Box(); F �� constructor ������ JCheck. Box(String text) JCheck. Box(String text, boolean b) F �� method true/false ������� check. Box ���� Obj. set. Selected(boolean b) Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All Obj. is. Selected() //return true/false on Obj. Check. Bok rights reserved. 0 -13 -222158 -6 3

JCheck. Box inherits all the properties such as text, icon, mnemonic, vertical. Alignment, horizontal.

JCheck. Box inherits all the properties such as text, icon, mnemonic, vertical. Alignment, horizontal. Text. Position, vertical. Text. Position, and selected from Abstract. Button, and provides several constructors to create check boxes. Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 4

Radio. Button F ��������������������� F ������� JRadio. Button ����� F ������� Button. Group �������

Radio. Button F ��������������������� F ������� JRadio. Button ����� F ������� Button. Group ������� F Radio. Button Constructor JRadio. Button() JRadio. Button(Icon icon) JRadio. Button(String text) Button. Group() Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 5 F ����������� Create. Radio 1. java

Event Hangling Component Event Interface Class ���� Override JRadio. Button Item. Listener item. State.

Event Hangling Component Event Interface Class ���� Override JRadio. Button Item. Listener item. State. Changed(Item. Event e) JCheck. Box Item. Listener item. State. Changed(Item. Event e) -get. Item. Selectable() iตรวจสอบ Checkbox นนๆถกคลกหรอไม Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 6

JRadio. Button Radio buttons are variations of check boxes. They are often used in

JRadio. Button Radio buttons are variations of check boxes. They are often used in the group, where only one button is checked at a time. Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 7

Grouping Radio Buttons Button. Group btg = new Button. Group(); btg. add(jrb 1); btg.

Grouping Radio Buttons Button. Group btg = new Button. Group(); btg. add(jrb 1); btg. add(jrb 2); Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 8

List ���������������������� F JList list = new JList(); F �� constructor JList() JList(Object item[])

List ���������������������� F JList list = new JList(); F �� constructor JList() JList(Object item[]) F �� method set. Fixed. Cell. Width(int i) set. Visble. Row. Count(int i) //Set ������� List // set ����������� get. Selected. Index() //return ����������� List set. Selected. Index(int i) Liang, Introduction to Java Programming, Sixth Edition, (c)//Set 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 9

Event Hangling Component ���� Interface Class Event List. Selection. Listener JList Override value. Changed(List.

Event Hangling Component ���� Interface Class Event List. Selection. Listener JList Override value. Changed(List. Selection. Event e) -get. Source() iใชในการคนคาวาปมใดถกกด -get. Text() iสำหรบดงขอความจาก -set. Text() iสำหรบกำหนดขอความ -get. Selected. Index() iจะคนคาตำแหนงรายการใน -get. Selected. Value() iจะคนขอความทอยใน Text นนๆ list ทถกเลอก list Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 10

JList A list is a component that performs basically the same function as a

JList A list is a component that performs basically the same function as a combo box, but it enables the user to choose a single value or multiple values. Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 11

JList Constructors F JList() Creates an empty list. F JList(Object[] string. Items) Creates a

JList Constructors F JList() Creates an empty list. F JList(Object[] string. Items) Creates a new list initialized with items. Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 12

JList Properties F selected. Indexd F selected. Indices F selected. Values F selection. Mode

JList Properties F selected. Indexd F selected. Indices F selected. Values F selection. Mode F visible. Row. Count Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 13

Combo Box F ���������� List ���� 1 �������� F JCombo. Box com = new

Combo Box F ���������� List ���� 1 �������� F JCombo. Box com = new JCombo. Box(); Constructor JCombo. Box() JCombo. Box(Object item[]) F ������� set. Maximum. Row. Count)int i) //���������� combo Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 14

Event Hangling Component ���� Interface Class Event Action. Listener JCombo. Box Override action. Performed(Action.

Event Hangling Component ���� Interface Class Event Action. Listener JCombo. Box Override action. Performed(Action. Event e) get. Source() iใชในการคนคาวาปมใดถกกด get. Text() iสำหรบดงขอความจาก set. Text() iสำหรบกำหนดขอความ get. Selected. Index() ทถกเลอก iจะคนคาตำแหนงรายการใน get. Selected. Item() iจะคนขอความทอยใน Text นนๆ Combo. Box Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 15

JCombo. Box A combo box is a simple list of items from which the

JCombo. Box A combo box is a simple list of items from which the user can choose. It performs basically the same function as a list, but can get only one value. Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 16

JCombo. Box Methods To add an item to a JCombo. Box jcbo, use jcbo.

JCombo. Box Methods To add an item to a JCombo. Box jcbo, use jcbo. add. Item(Object item) To get an item from JCombo. Box jcbo, use jcbo. get. Item() Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 17

Menu F ��������������������� F �������� § ����� Menu bars ��� Class “JMenu. Bar” §

Menu F ��������������������� F �������� § ����� Menu bars ��� Class “JMenu. Bar” § ����� Menu ��� Class “JMenu” § ����� Menu Item ������ Menu ��� Class “JMenu. Item” ���� Subclass ��� Class JMenu. Item § ����� Menu ������ Menu bars § ����� Menu bar ������ Frame ��� “set. JMenu. Bar()” Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 18

Menu F F Constructor JMenu. Bar() JMenu(String text) JMenu. Item(String text) Method add. Separator()

Menu F F Constructor JMenu. Bar() JMenu(String text) JMenu. Item(String text) Method add. Separator() Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 19

Event Hangling Component ���� Interface Class Event Action. Listener JMenu. Item -get. Source() Override

Event Hangling Component ���� Interface Class Event Action. Listener JMenu. Item -get. Source() Override action. Performed(Action. Event e) iใชในการคนคาวาปมใดถกเลอก Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved. 0 -13 -222158 -6 20