View Javadoc
1   package edu.jiangxin.apktoolbox.help.settings;
2   
3   import edu.jiangxin.apktoolbox.swing.extend.EasyChildTabbedPanel;
4   import edu.jiangxin.apktoolbox.utils.Constants;
5   
6   import javax.swing.*;
7   
8   public class AlwaysOnTopPanel extends EasyChildTabbedPanel {
9       private JPanel optionPanel;
10  
11      @Override
12      public void createUI() {
13          BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
14          setLayout(boxLayout);
15  
16          createOptionPanel();
17          add(optionPanel);
18  
19          add(Box.createVerticalStrut(15 * Constants.DEFAULT_Y_BORDER));
20      }
21  
22      private void createOptionPanel() {
23          optionPanel = new JPanel();
24          optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
25  
26          JLabel typeLabel = new JLabel("Always on top:");
27          JCheckBox alwaysOnTopCheckBox = new JCheckBox();
28          alwaysOnTopCheckBox.setSelected(conf.getBoolean("always.on.top", false));
29          alwaysOnTopCheckBox.addActionListener(e -> {
30              conf.setProperty("always.on.top", alwaysOnTopCheckBox.isSelected());
31              getFrame().setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
32              SwingUtilities.updateComponentTreeUI(getFrame());
33              getFrame().refreshSizeAndLocation();
34          });
35  
36          optionPanel.add(typeLabel);
37          optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
38          optionPanel.add(alwaysOnTopCheckBox);
39      }
40  }