JComponent
class, by instantiating the following pattern:
import java.awt.*; import javax.swing.*; public class subclass name extends JComponent { ... public void paint(Graphics g) { // Drawing statements go here } }
and then , attach a new instance of the JComponent
subclass to a
JFrame
instance's content pane by adding the following statement to
the frame constructor:
getContentPane().add(position, subclass instance);
The position can be "Center"
, "North"
, "East"
,
"South"
, or "West"
.
drawLine
statement to
the paint
method defined in a subclass of the JComponent
class.
width
and height
variables of the Dimension
instance produced by the getSize
method.
paint
method defined in a subclass of the
JComponent
class, then use getters such as getColor
.
paint
method defined in a subclass of the
JComponent
class, then use setters such as setColor
.