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

jiangxincode / ApkToolBoxGUI / #734

19 May 2024 01:23PM UTC coverage: 3.151%. Remained the same
#734

push

jiangxincode
merge some menu to settings menu

0 of 127 new or added lines in 11 files covered. (0.0%)

229 existing lines in 9 files now uncovered.

236 of 7489 relevant lines covered (3.15%)

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/help/settings/LookAndFeelPanel.java
1
package edu.jiangxin.apktoolbox.help.settings;
2

3
import edu.jiangxin.apktoolbox.swing.extend.EasyChildTabbedPanel;
4
import edu.jiangxin.apktoolbox.utils.Constants;
5
import org.apache.commons.lang3.ArrayUtils;
6
import org.apache.commons.lang3.StringUtils;
7

8
import javax.swing.*;
9
import java.awt.event.ActionEvent;
10
import java.awt.event.ActionListener;
11

NEW
12
public class LookAndFeelPanel extends EasyChildTabbedPanel {
×
13

14
    private JPanel optionPanel;
15

16
    private JComboBox<String> typeComboBox;
17

18
    private JPanel operationPanel;
19

20
    static {
21
        // Avoid install duplicated Look And Feel, we install them in static block
22
        UIManager.installLookAndFeel("Flat Light", "com.formdev.flatlaf.FlatLightLaf");
×
23
        UIManager.installLookAndFeel("Flat Dark", "com.formdev.flatlaf.FlatDarkLaf");
×
24
        UIManager.installLookAndFeel("Flat IntelliJ", "com.formdev.flatlaf.FlatIntelliJLaf");
×
25
        UIManager.installLookAndFeel("Flat Darcula", "com.formdev.flatlaf.FlatDarculaLaf");
×
UNCOV
26
    }
×
27

28
    @Override
29
    public void createUI() {
UNCOV
30
        BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
×
31
        setLayout(boxLayout);
×
32

33
        createOptionPanel();
×
34
        add(optionPanel);
×
35

36
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
37

UNCOV
38
        createOperationPanel();
×
UNCOV
39
        add(operationPanel);
×
40

NEW
41
        add(Box.createVerticalStrut(15 * Constants.DEFAULT_Y_BORDER));
×
42
    }
×
43

44
    private void createOptionPanel() {
45
        optionPanel = new JPanel();
×
46
        optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
×
47

48
        JLabel typeLabel = new JLabel("Type:");
×
49
        typeComboBox = new JComboBox<>();
×
50

UNCOV
51
        UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
×
52
        if (ArrayUtils.isEmpty(lookAndFeelInfos)) {
×
53
            typeComboBox.setEnabled(false);
×
54
        } else {
55
            typeComboBox.setEnabled(true);
×
56
            String className = conf.getString("look.and.feel.class.name");
×
57
            for (UIManager.LookAndFeelInfo info : lookAndFeelInfos) {
×
UNCOV
58
                typeComboBox.addItem(info.getName());
×
UNCOV
59
                if (StringUtils.equals(className, info.getClassName())) {
×
UNCOV
60
                    typeComboBox.setSelectedItem(info.getName());
×
61
                }
62
            }
63
        }
64

65
        optionPanel.add(typeLabel);
×
UNCOV
66
        optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
UNCOV
67
        optionPanel.add(typeComboBox);
×
68
    }
×
69

70
    private void createOperationPanel() {
71
        operationPanel = new JPanel();
×
72
        operationPanel.setLayout(new BoxLayout(operationPanel, BoxLayout.X_AXIS));
×
73

74
        JButton applyButton = new JButton("Apply");
×
75
        applyButton.addActionListener(new ApplyButtonActionListener());
×
76

77
        operationPanel.add(applyButton);
×
UNCOV
78
    }
×
79

80
    private final class ApplyButtonActionListener implements ActionListener {
×
81
        @Override
82
        public void actionPerformed(ActionEvent actionEvent) {
83
            String name = (String) typeComboBox.getSelectedItem();
×
84
            String className = getLookAndFeelClassNameFromName(name);
×
UNCOV
85
            if (className == null) {
×
86
                logger.warn("className is null");
×
UNCOV
87
                return;
×
88
            }
89
            conf.setProperty("look.and.feel.class.name", className);
×
90
            try {
91
                UIManager.setLookAndFeel(className);
×
92
            } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
×
93
                logger.error("setLookAndFeel failed, use default instead", e);
×
94
            }
×
UNCOV
95
            SwingUtilities.updateComponentTreeUI(getFrame());
×
UNCOV
96
            getFrame().refreshSizeAndLocation();
×
UNCOV
97
        }
×
98
    }
99

100
    private String getLookAndFeelClassNameFromName(String name) {
101
        UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
×
UNCOV
102
        for (UIManager.LookAndFeelInfo info : lookAndFeelInfos) {
×
UNCOV
103
            if (StringUtils.equals(name, info.getName())) {
×
104
                return info.getClassName();
×
105
            }
106
        }
UNCOV
107
        return null;
×
108
    }
109
}
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