CS 121 Lecture 23: Graphical Representation

16 views4 pages

Document Summary

Graphical representation: state & behavior of an object might include some info about what the object looks like visually: might contain data about its size & color, may also contain methods to draw it. Ex: this program display a smiling face & a text caption. // creates the main frame of the program. public static void main(string[] args) { // demonstrate the use of a separate panel class. import javax. swing. jframe; public class smilingface { frame. pack(); frame. setvisible(true); The main method in the smilingface class sets up the frame for the program & uses it to display an instantiation of the. Instead of adding gui components to this panel, we are simply drawing it. Extends the jpanel class: the extends class establishes an inheritance relationship. Inherits the characteristics of the jpanel class: the smilingfacepanel class is a jpanel. Constructor of the class sets the following: background color, preferred size of the pane, setting the panel"s default font.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents