Java: JPanel - Example
This page discusses - Java: JPanel - Example.
Images - ImageIcon
This simple approach loads the image "synchronously", meaning that whenever you request an image to be loaded, the program waits until the image loading is finished..
Mouse Buttons, Modifier Keys
Java supports up to three mouse buttons..
Mouse Listeners
There are several styles for using the mouse listeners..
MouseMotionListener
To implement a MouseMotionListener.
MouseListener
A mouse button is pressed, released, or the mouse enters or leaves the area of the component with a listener..
The Mouse
The mouse is handled automatically by most components, so you never have to know about it..
KeyDemo
Know about the KeyDemo.
Keyboard
Focus - Which component gets KeyEvents?.
Antialiasing
Antialiased versus Aliased Graphics.
Graphics2D
The javax.swing.Graphics2D class of Java 2 supports many more graphics operations than the Graphics class..
JPanel - Drawing Area 2
To initialize the panel -- Constructor.
JPanel - Drawing Area
Define a new class that extends JPanel and define a paintComponent method in it..
Images - BufferedImage
You can create a new BufferedImage using either the characteristics of an existing component ..
Polygons
Use the addPoint(int xcoord, int ycoord) method to add one point to the polygon..
Color
Predefines a few color constants.
Who calls paintComponent
you subclass JPanel to draw graphics, override the paintComponent() method..
Graphics class
The Graphics class contains drawing methods..
Screen Coordinates
You known the Screen Coordinates.
Drawing
It is easy to use, and can be used with the Color class to set the drawing color and Font class to set the font for drawing text..