当前位置:网站首页>Why can swing implement a form program by inheriting the JFrame class?
Why can swing implement a form program by inheriting the JFrame class?
2022-07-06 14:43:00 【in a cocoon around oneself.】
1. javax.swing.JFrame
1.1 JFrame Hierarchical structure
- Class JFrame
- java.lang.Object
- java.awt.Component
- java.awt.Container
- java.awt.Window
- java.awt.Frame
- javax.swing.JFrame
- java.awt.Frame
- java.awt.Window
- java.awt.Container
- java.awt.Component
- java.lang.Object
stay java api 8 Chinese vs Class JFrame It's described like this :
java.awt.frame Extended version of , It's for JFC / Swing Component architecture adds support .
Warning: Swing is not thread safe. For more information see Swing’s Threading Policy. Swing Not thread safe .
1.2 JFrame Medium Nested Classes ( Inner class )
- JFrame.AccessibleJFrame
This kind of implementation JFrame Class accessibility support .
protected class AccessibleJFrame extends AccessibleAWTFrame {
// AccessibleContext methods
/** * Get the accessible name of this object. * * @return the localized name of the object -- can be null if this * object does not have a name */
public String getAccessibleName() {
if (accessibleName != null) {
return accessibleName;
} else {
if (getTitle() == null) {
return super.getAccessibleName();
} else {
return getTitle();
}
}
}
/** * Get the state of this object. * * @return an instance of AccessibleStateSet containing the current * state set of the object * @see AccessibleState */
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
if (isResizable()) {
states.add(AccessibleState.RESIZABLE);
}
if (getFocusOwner() != null) {
states.add(AccessibleState.ACTIVE);
}
// FIXME: [[[WDW - should also return ICONIFIED and ICONIFIABLE
// if we can ever figure these out]]]
return states;
}
} // inner class AccessibleJFrame
AccessibleJFrame Realized awt Medium AccessibleAWTFrame Interface
This class implements the auxiliary function support of the window class .
It provides... Suitable for window user interface elements Java Accessibility API The implementation of the .
- public String getAccessibleName() Localized name of the object , Can be null
Component How to implement the interface
The implementation logic is to get accessibleName If it is not empty, return accessibleName, Otherwise, get the form title ,title If it is empty, take the parent class accessibleName , Otherwise return to title
- public AccessibleStateSet getAccessibleStateSet() Get the status of the current object Overriding the parent class awt in Fram Methods
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
if (isResizable()) {
states.add(AccessibleState.RESIZABLE);
}
if (getFocusOwner() != null) {
states.add(AccessibleState.ACTIVE);
}
// FIXME: [[[WDW - should also return ICONIFIED and ICONIFIABLE
// if we can ever figure these out]]]
return states;
}
Logic : The parent object call gets the window state object reference , Gets whether this window is available for user adjustment , If yes, add one AccessibleState.RESIZABLE Indicates that the current window is not fixed . Get that the window has focus , If yes, it will be added as AccessibleState.ACTIVE Indicates that the current window is active .
1.3 JFram Medium Fields ( Property fields )
- protected AccessibleContextaccessibleContext Accessible context properties .
- static int EXIT_ON_CLOSE Exit the default window closing operation of the application .
- protected JRootPane rootPane tube The reason is ContentPane And... In the optional menu of this window JrootPane Examples and Glasspane.
- protected boolean rootPaneCheckingEnabled If true, Will add and setLayout The call will be forwarded to ContentPane.
contentPane
swing Four heavyweight components in JFrame, JDialog, JWindow, and JApplet
JROOTPANE The custom layout manager used ensures :
Glasspane Filled jrootpane The entire visible area of ( The border - Jack ).
DiallayPane Filled Jrootpane The entire visible area of .
( The border - Insert )
The incubator is located on the upper edge of the cover .
ContentPane Fill the entire visible area , If there is , Subtract the menu bar .
1.4 JFram Constructors ( Constructors )
- JFrame() Initial parameterless constructor
- JFrame(GraphicsConfiguration gc) Create a form in the specified graphic configuration and blank title of the screen device
- JFrame(String title) Create a new initial invisible form with the specified title
- JFrame(String title, GraphicsConfiguration gc) Create with the specified title and the specified graphic configuration of the screen device JFrame.
1.5 JFram Method Summary ( Only describe common methods )
- public void repaint(long time,
int x,
int y,
int width,
int height)
public void repaint(long time, int x, int y, int width, int height) {
if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
RepaintManager.currentManager(this).addDirtyRegion(
this, x, y, width, height);
}
else {
super.repaint(time, x, y, width, height);
}
}
Repaint the specified rectangle of this component in milliseconds .
time : The maximum time before updating is in milliseconds
x,y coordinate 、 Width and height
边栏推荐
- [pointer] find the largest string
- 《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
- “人生若只如初见”——RISC-V
- 《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
- 函数:字符串反序存放
- Load balancing ribbon of microservices
- Intel oneapi - opening a new era of heterogeneity
- Markdown font color editing teaching
- Flash implements forced login
- Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
猜你喜欢
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
Wu Enda's latest interview! Data centric reasons
Fundamentals of digital circuit (V) arithmetic operation circuit
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
Keil5-MDK的格式化代码工具及添加快捷方式
How does SQLite count the data that meets another condition under the data that has been classified once
数字电路基础(三)编码器和译码器
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
数据库多表链接的查询方式
关于超星脚本出现乱码问题
随机推荐
JDBC事务、批处理以及连接池(超详细)
The common methods of servlet context, session and request objects and the scope of storing data in servlet.
[pointer] find the value of the largest element in the two-dimensional array
内网渗透之内网信息收集(三)
Wang Shuang's detailed learning notes of assembly language II: registers
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
Quaternion -- basic concepts (Reprint)
刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
Uibutton status exploration and customization
To brush the video, it's better to see if you have mastered these interview questions. Slowly accumulating a monthly income of more than 10000 is not a dream.
flask实现强制登陆
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
Fundamentals of digital circuits (II) logic algebra
函数:字符串反序存放
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
【指针】八进制转换为十进制
XSS (cross site scripting attack) for security interview
【指针】删除字符串s中的所有空格