1 / 19

Enhancing User Interface with Swing Components

Learn how to create interactive user interfaces using Swing components in Java. Explore graphics handling and subclassing for functionality customization.

prentice
Download Presentation

Enhancing User Interface with Swing Components

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP3502: Introduction to CIS I Lecture 18

  2. java swing

  3. java swing import javax.swing.*;

  4. JFrame

  5. JFrame JComponent

  6. JFrame JComponent

  7. JFrame JComponent

  8. JComponents JPanel JLabel JSlider JScrollBar JPopupMenu JMenuBar …. many more!

  9. JComponents are abstract Add functionality by creating subclass of a JComponent public class MySuperAwesomePanel extends JPanel { // Panel functionality }

  10. 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

  11. window organization

  12. graphics import java.awt.Graphics;

  13. graphics import java.awt.Graphics; 1. contains all the information related to drawing graphics eg. Background and foreground colors, location, dimensions

  14. 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

  15. 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

  16. paintComponent() inherited from a JComponent does nothing on its own YOU must override and provide implementation

  17. Shape Class import java.awt.geom.*;

More Related