View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.demo.gui;
6   
7   import java.awt.BorderLayout;
8   import java.awt.Dimension;
9   
10  import javax.swing.BorderFactory;
11  import javax.swing.JLabel;
12  import javax.swing.JPanel;
13  
14  /**
15   * Parent class combining code common to the other panels.
16   */
17  public class OshiJPanel extends JPanel {
18  
19      private static final long serialVersionUID = 1L;
20  
21      protected JLabel msgLabel = new JLabel();
22      protected JPanel msgPanel = new JPanel();
23  
24      public OshiJPanel() {
25          Dimension maxSize = getMaximumSize();
26          if (maxSize != null) {
27              setSize(maxSize);
28          }
29          setLayout(new BorderLayout());
30          setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
31          msgPanel.add(msgLabel);
32  
33          JPanel topPanel = new JPanel(new BorderLayout());
34          topPanel.add(msgPanel, BorderLayout.CENTER);
35          add(topPanel, BorderLayout.NORTH);
36      }
37  }