GUI graphical user interface GUI friendly InputOutput dialogs

  • Slides: 22
Download presentation

GUI • graphical user interface (GUI) ����������� (friendly)

GUI • graphical user interface (GUI) ����������� (friendly)

Input/Output dialogs • Dialog ���������� method ���� show. Input. Dialog ���� • JOption. Pane.

Input/Output dialogs • Dialog ���������� method ���� show. Input. Dialog ���� • JOption. Pane. show. Input. Dialog( "Enter first integer" ) • ������� expression ����� type ��� String – Ok ��������

Input/Output dialogs • Dialog ���������� method ���� show. Message. Dialog • show. Message. Dialog(

Input/Output dialogs • Dialog ���������� method ���� show. Message. Dialog • show. Message. Dialog( null, "The sum is " + sum, "Sum of Two Integers", JOption. Pane. PLAIN_MESSAGE )

Example

Example

swing-JPanel • ����������� – ������� JPanel jp = new JPanel(); – �������� JFrame •

swing-JPanel • ����������� – ������� JPanel jp = new JPanel(); – �������� JFrame • JFrame. set. Content. Pane(JPanel);

swing-JLabel • JLabel ���������� – ������� JLabel label 1 = new JLabel(“My text”); –

swing-JLabel • JLabel ���������� – ������� JLabel label 1 = new JLabel(“My text”); – ������� tooltip ��� label 1. set. Tool. Tip. Text( "This is label 1" ); • �������� JPanel. add(JLabel);

swing-JTextfield • ����������� 1 ����������� • ��������� object private JText. Field text. Field; text.

swing-JTextfield • ����������� 1 ����������� • ��������� object private JText. Field text. Field; text. Field = new JText. Field( "Enter text here" ); • ������ JPanel add( text. Field 2 );

Action. Listener

Action. Listener

JText. Field & Action. Listener • ����� Action. Listener ������ JText. Field. Handler handler

JText. Field & Action. Listener • ����� Action. Listener ������ JText. Field. Handler handler = new Text. Field. Handler(); text. Field. add. Action. Listener( handler );

JButton • ��������������������� • ��������� object private JButton plain. JButton; plain. JButton = new

JButton • ��������������������� • ��������� object private JButton plain. JButton; plain. JButton = new JButton( "Plain Button" ); • ������ JPanel add( plain. JButton );

Action. Listener

Action. Listener

JButton & Action. Listener • ����� Action. Listener ������ JButton. Handler handler = new

JButton & Action. Listener • ����� Action. Listener ������ JButton. Handler handler = new Button. Handler(); plain. JButton. add. Action. Listener( handler );

����� • Java How to program : H. M. Deitel

����� • Java How to program : H. M. Deitel