Skip to Main Content
Java
book

Java

by Michael Sikora
January 2003
Beginner to intermediate content levelBeginner to intermediate
150 pages
7h 28m
English
Morgan Kaufmann
Content preview from Java
1 30
Chapter 8: Developing
GUIs []
10
11
12
13
14 }
public void paintComponent (Graphics g) {
super, paintComponent (g) ;
g.drawString("Text to be drawn" , 20, getHeight()
}
);
PaintPanel
The constructor, PaintPanel, uses the javax, swing. 3Panel. setPreferredSize method to set the
size of the panel, in this case, 1 I0 pixels wide and 24 pixels high. The first statement in the
paintComponent method must be
super, paintComponent (g) ;
This causes the component to paint its background. The java. awt. Graphics. drawString method
is used to paint the text. Two useful methods in javax, swing. 3Component that can be used with
drawstring are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Programming

Java Programming

Hari Mohan Pandey
Java Programming

Java Programming

Poornachandra Sarang
JAVA Programming

JAVA Programming

K. Rajkumar
Java 9 for Programmers

Java 9 for Programmers

Paul J. Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781558609099