• Tidak ada hasil yang ditemukan

Programming in Java

N/A
N/A
Protected

Academic year: 2024

Membagikan "Programming in Java"

Copied!
6
0
0

Teks penuh

(1)

Programming in Java

CBCS BHCS03

By Parul Chachra

(2)

Chapter 31

Introducing Swing

Reference: Schildt, H. Java: The Complete Reference. 7th ediEon. McGraw-

Hill EducaEon

(3)

Components

•  In general, Swing components are derived from the JComponent class

•  JComponent provides the funcEonality that is common to all components

•  For example, JComponent supports the pluggable look and feel

•  JComponent inherits the AWT classes Container and Component

•  Thus, a Swing component is built on and

compaEble with an AWT component

(4)

Components

•  All of Swing’s components are represented by

classes defined within the package javax.swing:

(5)

Containers

•  Swing defines two types of containers

– Lightweight Containers – Top-level containers

(6)

Lightweight Containers

•  Lightweight containers do inherit JComponent

•  An example of a lightweight container is JPanel, which is a general-purpose container

•  Lightweight containers are oTen used to organize and manage groups of related components because a lightweight container can be contained within

another container

•  Thus, you can use lightweight containers such as JPanel to create subgroups of related controls that are contained within an outer container

Referensi

Dokumen terkait

The C++ standard library containers were designed to meet two criteria: to provide the maximum freedom in the design of an individual container, while at the same time

aegypti mosquito eggs on various types of container materials / water containers, then an experiment was conducted by placing 5 kinds of containers in a mosquito cage containing

As a second example, the Java compiler javac transforms a .java source file into a .class file that is written in Java bytecode , which is the machine language for an

A class, in the context of Java, are templates that are used to create objects, and to define object data types and methods.. For

A Simple Swing ApplicaEon • Swing programs differ from both the console-based programs and the AWT-based programs, for example, – They use a different set of components and a different

Inner Classes • An inner class is a class defined within another class • Inner classes can be used to simplify the code when using event adapter classes • The following applet

A Simple Swing ApplicaEon • main is executed on the main thread • Thus, main cannot directly instanEate a SwingDemo object • Instead, it must create a Runnable object that

• Its signature is shown here: int getClickCount • getBuPon method returns a value that represents the buPon that caused the event: int getBuPon • The return value will be one