Abstract Window Toolkit (AWT),
eclipse 使用SWT
7.1 创建框架
AWT Frame
SWing JFrame
事件分派线程:
EventQueue.invokeLater(new Runnable()
{
public void run()
{
SimpleFrame frame = new SimpleFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
ToolKit 类 与本地窗口系统相关
多屏幕GraphicsEnvironment和GraphicsDevice来获得显示屏大小
GraphicsDevice类允许在全屏模式下执行应用程序
7.4 在组件中显示信息
7.5 处理2D图形
自从Java SE 2 以来,paintComponent 方法自动获得一个Graphics2D类对象,用户只需一次类型转换
awt.geom包
7.6 使用颜色
java.awt.Graphics 1.0
• Color getColor()
• void setColor(Color c)
java.awt.Graphics2D 1.2
• Paint getPaint()
• void setPaint(Paint p)
java.awt.Component 1.0
• Color getBackground()
• void setBackground(Color c)
Color getForeground()
void setForeground(Color c)
7.7 文本使用特殊字体
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
关于字体的排版详见 corejava 7.7
7.8 显示图像
Image image = new ImageIcon(filename).getImage();