AWT and Swing Hierarchy (see Figure C.3)
JFrame Common Methods (see Figure C.4)
- Container getContentPane()
- void setDefaultCloseOperation(int operation)
- setContentPane(Container contentPane)
- void setTitle(String title)
- void setMenuBar(MenuBar bm)
- void setSize(int width, int height)
- void pack()
- void show() Note: show() is deprecated, use setVisible(true)
JPanel Common Methods
- JPanel()
- JPanel(LayoutManager layout)
- void add(Component c)
- void paintComponent(Graphics g)
- void repaint()
Graphics Common Methods
- void drawLine(int x1, int y1, int x2, int y2)
- void drawOval(int x, int y, int width, int height)
- void fillOval(int x, int y, int width, int height)
- void drawPolygon(Polygon p)
- void fillPolygon(Polygon p)
- void drawRect(int x, int y, int width, int height)
- void fillRect(int x, int y, int width, int height)
- Color getColor()
- void setColor(Color c)
Lecture Code