Presentation is loading. Please wait.

Presentation is loading. Please wait.

SE-1020 Dr. Mark L. Hornick 1 Graphical User Interfaces.

Similar presentations


Presentation on theme: "SE-1020 Dr. Mark L. Hornick 1 Graphical User Interfaces."— Presentation transcript:

1 SE-1020 Dr. Mark L. Hornick 1 Graphical User Interfaces

2 SE-1020 Dr. Mark L. Hornick 2 You’ve already done some Java GUI programming JOptionPane - a multi-purpose class whose behavior varies based on which static method you invoke showMessageDialog showInputDialog showConfirmDialog showOptionDialog

3 SE-1020 Dr. Mark L. Hornick 3 JOptionPane. showMessageDialog() provides a simple way to display a message to the user: JOptionPane.showMessageDialog(null, “I Love Java”);

4 SE-1020 Dr. Mark L. Hornick 4 JOptionPane. showInputDialog() provides a way to prompt the user for some text input: String text = JOptionPane.showInputDialog(null, "Enter some text:", "Input dialog", JOptionPane.QUESTION_MESSAGE);

5 SE-1020 Dr. Mark L. Hornick 5 JOptionPane.showConfirmDialog() provides a way to present a variety of standard button choices to the user: response = JOptionPane.showConfirmDialog( null, "Run Again?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );

6 SE-1020 Dr. Mark L. Hornick 6 JOptionPane.showOptionDialog() provides A way to customize the options presented to the user beyond the standard choices: Object[] options = { “Bye" }; JOptionPane.showOptionDialog(null, "Game over; you're broke.", "Please come again", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);

7 SE-1020 Dr. Mark L. Hornick 7 There are a lot more GUI classes than just JOptionPane These are in two different packages AWT (Abstract Window Toolkit) classes are implemented by using the native GUI objects AWT classes for Windows are written differently than AWT classes written for the MAC A GUI application written on for a MAC will look different than one written for a Windows-based PC Swing classes are fully implemented in Java, and behave the same on different operating systems. They provide greater compatibility across different operating systems (JOptionPane is part of javax.swing)

8 SE-1020 Dr. Mark L. Hornick 8 Swing classes support many more functionalities not supported by AWT counterparts Rules for usage: Do not mix the counterparts (e.g. AWT buttons and Swing buttons) in the same program because of their differences in implementation. UNLESS there is no Swing counterpart to AWT (e.g. AWT Graphics) then it is OK to use AWT.

9 SE-1020 Dr. Mark L. Hornick 9 JTextField JLabel JFrameJButton The JFrame class is the fundamental “window” class It contains rudimentary functionalities to support features found in any frame window. A JFrame object serves as the “host” for containing other components,


Download ppt "SE-1020 Dr. Mark L. Hornick 1 Graphical User Interfaces."

Similar presentations


Ads by Google