没有合适的资源?快使用搜索试试~ 我知道了~
JavaSE程序设计课件:L03-GUI Programming - 1.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 172 浏览量
2022-05-28
20:27:19
上传
评论
收藏 634KB PDF 举报
温馨提示
试读
38页
JavaSE程序设计课件:L03-GUI Programming - 1.pdf
资源推荐
资源详情
资源评论
1
Chapter 11
Getting Started with GUI Programming
2
Creating GUI Objects
// Create a button with text OK
JButton jbtOK = new JButton("OK");
// Create a label with text "Enter your name: "
JLabel jlblName = new JLabel("Enter your name: ");
// Create a text field with text "Type Name Here"
JTextField jtfName = new JTextField("Type Name Here");
// Create a check box with text bold
JCheckBox jchkBold = new JCheckBox("Bold");
// Create a radio button with text red
JRadioButton jrbRed = new JRadioButton("Red");
// Create a combo box with choices red, green, and blue
JComboBox jcboColor = new JComboBox(new String[]{"Red",
"Green", "Blue"});
Button
Label Text
field
Check
Box
Radio
Button
Combo
Box
3
Swing vs. AWT
So why do the GUI component classes have a prefix J? Instead of
JButton, why not name it simply Button? In fact, there is a class
already named Button in the java.awt package.
When Java was introduced, the GUI classes were bundled in a
library known as the Abstract Windows Toolkit (AWT).
With the release of Java 2, the AWT user-interface components were
replaced by a more robust, versatile, and flexible library known as
Swing components.
Swing components are less dependent on the target platform and use
less of the native GUI resource.
For this reason, Swing components that don’t rely on native GUI are
referred to as lightweight components, and AWT components are
referred to as heavyweight components.
4
Container Classes
Dimension
Font
FontMetrics
Component
Graphics
Object
Color
Container
Panel
Applet
Frame
Dialog
Window
JComponent
JApplet
JFrame
JDialog
Swing Components
in the javax.swing package
Lightweight
Heavyweight
Classes in the java.awt
package
1
LayoutManager
*
JPanel
Container classes can
contain other GUI
components.
5
GUI Helper Classes
Dimension
Font
FontMetrics
Component
Graphics
Object
Color
Container
Panel
Applet
Frame
Dialog
Window
JComponent
JApplet
JFrame
JDialog
Swing Components
in the javax.swing package
Lightweight
Heavyweight
Classes in the java.awt
package
1
LayoutManager
*
JPanel
The helper classes are not
subclasses of Component. They are
used to describe the properties of
GUI components such as graphics
context, colors, fonts, and
dimension.
剩余37页未读,继续阅读
资源评论
wxg520cxl
- 粉丝: 24
- 资源: 3万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功