190 likes | 260 Views
COP3502: Introduction to CIS I. Lecture 18. j ava swing. j ava swing i mport javax.swing .*;. JFrame. JFrame. JComponent. JFrame. JComponent. JFrame. JComponent. JComponents JPanel JLabel JSlider JScrollBar JPopupMenu JMenuBar …. m any more!. JComponents are abstract
E N D
COP3502: Introduction to CIS I Lecture 18
java swing import javax.swing.*;
JFrame JComponent
JFrame JComponent
JFrame JComponent
JComponents JPanel JLabel JSlider JScrollBar JPopupMenu JMenuBar …. many more!
JComponents are abstract Add functionality by creating subclass of a JComponent public class MySuperAwesomePanel extends JPanel { // Panel functionality }
nested classes classes declared within the body of another class ALWAYS “private static class” good for managing many small classes that make up a larger class
graphics import java.awt.Graphics;
graphics import java.awt.Graphics; 1. contains all the information related to drawing graphics eg. Background and foreground colors, location, dimensions
graphics import java.awt.Graphics; 1. contains all the information related to drawing graphics eg. Background and foreground colors, location, dimensions 2. contains methods for actually drawing graphics to screen eg. Shapes, text, and images
graphics import java.awt.Graphics; Graphics is an abstract class You cannot instantiate a Graphics object on your own typically created by the JComponent and given to the component’s paint() or paintComponent() method
paintComponent() inherited from a JComponent does nothing on its own YOU must override and provide implementation
Shape Class import java.awt.geom.*;