Painting JComponent Objects : JComponent « Swing « Java Tutorial

Painting JComponent Objects
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JFrame;

class MyComponent extends JComponent {
  protected void paintComponent(Graphics g) {
    // Customize after calling super.paintComponent(g)



public class PaintingJComponentObjects {
  public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(30, 30, 300, 300); // Size

    MyComponent com = new MyComponent();


    aWindow.setVisible(true); // Display the window

14.2.2.HTML formatting by setting the text on a labelHTML formatting by setting the text on a label
14.2.3.Listening to Inherited Events of a JComponent from Container and Component
14.2.4.Painting JComponent ObjectsPainting JComponent Objects an icon is adapted to a component
14.2.6.A Swing component that computes and displays a fractal image known as a 'Julia set'
14.2.7.Extends JComponent to create drawing pad
14.2.8.A panel that displays a paint sample.