• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #1207

13 Sep 2025 11:58PM UTC coverage: 2.895% (-0.006%) from 2.901%
#1207

push

jiangxincode
fix #569: 可能在完全初始化子类之前逃逸了 'this'

0 of 32 new or added lines in 22 files covered. (0.0%)

9 existing lines in 8 files now uncovered.

248 of 8567 relevant lines covered (2.89%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/swing/extend/EasyFrame.java
1
package edu.jiangxin.apktoolbox.swing.extend;
2

3
import java.awt.*;
4
import java.awt.event.WindowAdapter;
5
import java.awt.event.WindowEvent;
6
import java.util.ResourceBundle;
7

8
import javax.swing.JFrame;
9

10
import org.apache.commons.configuration2.Configuration;
11
import org.apache.logging.log4j.LogManager;
12
import org.apache.logging.log4j.Logger;
13

14
import edu.jiangxin.apktoolbox.utils.Utils;
15

16
/**
17
 * @author jiangxin
18
 * @author 2018-09-09
19
 *
20
 */
21
public class EasyFrame extends JFrame {
22
    private static final long serialVersionUID = 1L;
23
    protected transient Logger logger;
24
    protected transient Configuration conf;
25
    protected transient ResourceBundle bundle;
26
    protected transient Image image;
27

28
    public EasyFrame() throws HeadlessException {
29
        super();
×
30
        logger = LogManager.getLogger(this.getClass().getSimpleName());
×
31
        conf = Utils.getConfiguration();
×
32
        bundle = ResourceBundle.getBundle("apktoolbox");
×
NEW
33
    }
×
34

35
    // in case of escape of "this"
36
    public void initialize() {
UNCOV
37
        addWindowListener(new WindowAdapter() {
×
38
            @Override
39
            public void windowClosing(WindowEvent e) {
40
                super.windowClosing(e);
×
41
                onWindowClosing(e);
×
42
                Utils.saveConfiguration();
×
43
                logger.info("windowClosing: " + EasyFrame.this.getClass().getSimpleName());
×
44
            }
×
45
            @Override
46
            public void windowIconified(WindowEvent e) {
47
                super.windowIconified(e);
×
48
                onWindowIconified(e);
×
49
                setVisible(false);
×
50
                dispose();
×
51
                Utils.saveConfiguration();
×
52
                logger.info("windowIconified: " + EasyFrame.this.getClass().getSimpleName());
×
53
            }
×
54
        });
55
        Toolkit tk = Toolkit.getDefaultToolkit();
×
56
        image = tk.createImage(this.getClass().getResource("/icon.jpg"));
×
57
        setIconImage(image);
×
58
        logger.info("Frame start: " + this.getClass().getSimpleName());
×
59
    }
×
60

61
    public void refreshSizeAndLocation() {
62
        // use pack to resize the child component
63
        pack();
×
64
        setMinimumSize(new Dimension(800, 100));
×
65
        setResizable(false);
×
66

67
        // relocation this JFrame
68
        int windowWidth = getWidth();
×
69
        int windowHeight = getHeight();
×
70
        Toolkit kit = Toolkit.getDefaultToolkit();
×
71
        if (kit == null) {
×
72
            logger.error("kit is null");
×
73
            return;
×
74
        }
75
        Dimension screenSize = kit.getScreenSize();
×
76
        if (screenSize == null) {
×
77
            logger.error("screenSize is null");
×
78
            return;
×
79
        }
80
        int screenWidth = screenSize.width;
×
81
        int screenHeight = screenSize.height;
×
82
        setLocation(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2);
×
83
    }
×
84

85
    protected void onWindowClosing(WindowEvent e) {}
×
86

87
    protected void onWindowIconified(WindowEvent e) {}
×
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc