TAILIEUCHUNG - Lecture Fundamentals of computing 1: Lecture 14 - Duy Tan University

Lecture Fundamentals of computing 1: Lecture 14 introduce Graphic User Interface (GUI). This chapter presents the following content: Graphic User Interface (GUI), Jframe, event-driven programming, layout manager, components, mouse events, keyboard events, 2D graphics, animation with timers. | Lecture Title: Graphic User Interface (GUI) Fundamentals of Computing 1 Agenda JOptionPane Graphic User Interface (GUI) JFrame Event-Driven Programming Layout Manager Components Mouse events Keyboard events 2D Graphics Animation with Timers ask them, how might the computer store "hi" using binary digits? (some kind of mapping; ASCII) An option pane is a simple dialog box for graphical input/output Advantages: simple flexible (in some ways) looks better than the black box of death Disadvantages: created with static methods; not very object-oriented not very powerful (just simple dialog boxes) Graphical input and output with JOptionPane Types of JOptionPanes showMessageDialog(, ) Displays a message on a dialog with an OK button. showConfirmDialog(, ) Displays a message and list of choices Yes, No, Cancel; returns user's choice as an int with one of the following values: showInputDialog(, ) Displays a message and text field for input; returns the user's value entered as a String. NOTE: can pass null for the parent to all methods JOptionPane examples 1 showMessageDialog analogous to to display a message import .*; public class MessageDialogExample { public static void main(String[] args) { (null,"How's the weather?"); (null, "Second message"); } } JOptionPane examples 2 showConfirmDialog analogous to a that prints a question, then reading an input value from the user (can only be one of the provided choices) import .*; public class ConfirmDialogExample { public static void main(String[] args) { int choice = (null, "Erase your hard disk?"); if (choice == ) { (null, "Disk erased!"); } else { (null, "Cancelled."); } } } .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.