GraphicalUserInterfaces

GraphicalUserInterfaces - CSE 219 Computer Science III...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Half Life 2, by Valve, released 2004 CSE 219 Computer Science III Graphical User Interfaces
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
GUI Examples
Background image of page 2
GUI Graphical User Interface (GUI) provides user-friendly human interaction Building Java GUIs require use of multiple frameworks: Java’s GUI component Libraries javax.swing.* Java’s Event Programming Libraries java.awt.event.* Javax.swing.event.* Java’s Graphics Programming Libraries java.awt.* java.awt.geom.*
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
GUI Look vs. Behavior Look physical appearance custom component design containment layout management Behavior interactivity event programmed response
Background image of page 4
What does a GUI framework do for you? Provides ready made visible, interactive, customizable components you wouldn’t want to have to code your own window
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The JFrame Java’s top-level window a window that is not contained inside another window Has methods for: used to specify window to fit screen setExtendedState specifying a response to clicking window’s ‘X’ setDefaultCloseOperation specifying size and location (top-left corner) setSize , setLocation (inherited from Component ) Many other useful methods inherited from ancestors
Background image of page 6
javax.swing.JFrame Class Hierarchy Object Component Container Window Frame JFrame
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Useful Inherited Methods for JFrame s Frame setting window’s icon setIconImage(Image image) images can be loaded via: Toolkit.getDefaultToolkit.getImage(String fileName) Window for hiding window hide() for tightly packing all components inside frame pack() Component for displaying window setVisible(boolean b)
Background image of page 8
Defining your own JFrame class import java.awt.Image; import java.awt.Toolkit; import javax.swing.JFrame; public class MyEmptyFrame extends JFrame { public MyEmptyFrame() { super("MyEmptyFrame"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Toolkit tk = Toolkit.getDefaultToolkit(); Image frameIcon = tk.getImage("NYYankees.jpg"); setIconImage(frameIcon); setExtendedState(MAXIMIZED_BOTH); } } Sets frame title Sets frame icon Terminates program when frame closed Maximizes frame
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Displaying our MyEmptyFrame 1. Construct a MyEmptyFrame object 2. Call setVisible(true) to make the frame visible, this spawns a thread which:
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 30

GraphicalUserInterfaces - CSE 219 Computer Science III...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online