Basic Program Flashcards
JFrame
Window that contains a title/border. It is used to display graphics.
Double-Buffering
The act of drawing graphics off-screen (back buffer) and then copying the data to the main display (primary surface).
block line transfer (blitting)
The process of copying contents from the back buffer to the primary surface.
Page flipping
The act of alternating the value of the video pointer containing the video data to be drawn between the back buffer and the primary surface.
Abstract Window Toolkit (AWT)
Java’s original platform-dependent windowing, graphics, user-interface widget toolkit.
Swing
Java’s new GUI widget toolkit -> As it is written entirely in java, it is platform independent and aims to provide a more sophisticated control over graphics than the AWT.
Canvas
Class used to draw to the screen. A subclass that extends from canvas must be added to the JFrame using the add() method
Paint
void paint(graphics g) must be overridden, it is called when repaint() is called (generally from the main update method). super.paint() may be called to clear the canvas
Useful JFrame methods
add() -> used to add components like the canvas
addKeyListener()
pack() -> Sets components size
setVisible()
setPreferredSize(Dimension dim)
setDefaultCloseOperation(minimize/exit…)
KeyListener
A class can implement the KeyListener interface to override KeyPressed() / KeyReleased(). This class must be added to the JFrame using the addKeyListener() method