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..
There are several styles for using the mouse listeners..
To implement a MouseMotionListener.
A mouse button is pressed, released, or the mouse enters or leaves the area of the component with a listener..
The mouse is handled automatically by most components, so you never have to know about it..
Know about the KeyDemo.
Focus - Which component gets KeyEvents?.
Antialiased versus Aliased Graphics.
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 ..
Use the addPoint(int xcoord, int ycoord) method to add one point to the polygon..
Predefines a few color constants.
Who calls paintComponent
you subclass JPanel to draw graphics, override the paintComponent() method..
The Graphics class contains drawing methods..
You known the Screen Coordinates.
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..