当前位置:网站首页>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
边栏推荐
- 关于超星脚本出现乱码问题
- “人生若只如初见”——RISC-V
- Pointers: maximum, minimum, and average
- “Hello IC World”
- SystemVerilog discusses loop loop structure and built-in loop variable I
- Interview Essentials: what is the mysterious framework asking?
- 【指针】八进制转换为十进制
- Mathematical modeling idea of 2022 central China Cup
- How to earn the first pot of gold in CSDN (we are all creators)
- Keil5-MDK的格式化代码工具及添加快捷方式
猜你喜欢
JDBC事务、批处理以及连接池(超详细)
《统计学》第八版贾俊平第三章课后习题及答案总结
Binary search tree concept
王爽汇编语言详细学习笔记二:寄存器
Proceedingjoinpoint API use
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
The common methods of servlet context, session and request objects and the scope of storing data in servlet.
数字电路基础(二)逻辑代数
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
“Hello IC World”
随机推荐
[pointer] find the length of the string
Data mining - a discussion on sample imbalance in classification problems
Pointeurs: maximum, minimum et moyenne
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
Wu Enda's latest interview! Data centric reasons
【指针】求解最后留下的人
[pointer] find the largest string
关于交换a和b的值的四种方法
Numpy快速上手指南
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
【指针】统计一字符串在另一个字符串中出现的次数
数字电路基础(四) 数据分配器、数据选择器和数值比较器
《统计学》第八版贾俊平第一章课后习题及答案总结
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
JDBC事务、批处理以及连接池(超详细)
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
指针--剔除字符串中的所有数字
【指针】查找最大的字符串