View Javadoc
1   /*
2    * Tethys: GUI Utilities
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.tethys.swing.pane;
18  
19  import javax.swing.JPanel;
20  
21  import io.github.tonywasher.joceanus.tethys.api.base.TethysUIComponent;
22  import io.github.tonywasher.joceanus.tethys.core.factory.TethysUICoreFactory;
23  import io.github.tonywasher.joceanus.tethys.core.pane.TethysUICoreFlowPaneManager;
24  import io.github.tonywasher.joceanus.tethys.swing.base.TethysUISwingNode;
25  
26  /**
27   * Swing Flow Pane Manager.
28   */
29  public class TethysUISwingFlowPaneManager
30          extends TethysUICoreFlowPaneManager {
31      /**
32       * The Node.
33       */
34      private final TethysUISwingNode theNode;
35  
36      /**
37       * The Panel.
38       */
39      private final JPanel thePanel;
40  
41      /**
42       * Constructor.
43       *
44       * @param pFactory the factory
45       */
46      TethysUISwingFlowPaneManager(final TethysUICoreFactory<?> pFactory) {
47          super(pFactory);
48          thePanel = new JPanel();
49          theNode = new TethysUISwingNode(thePanel);
50      }
51  
52      @Override
53      public TethysUISwingNode getNode() {
54          return theNode;
55      }
56  
57      @Override
58      public void setVisible(final boolean pVisible) {
59          thePanel.setVisible(pVisible);
60      }
61  
62      @Override
63      public void addNode(final TethysUIComponent pNode) {
64          super.addNode(pNode);
65          thePanel.add(TethysUISwingNode.getComponent(pNode));
66      }
67  
68      @Override
69      public void setChildVisible(final TethysUIComponent pChild,
70                                  final boolean pVisible) {
71          TethysUISwingNode.getComponent(pChild).setVisible(pVisible);
72      }
73  
74      @Override
75      public void setPreferredWidth(final Integer pWidth) {
76          theNode.setPreferredWidth(pWidth);
77      }
78  
79      @Override
80      public void setPreferredHeight(final Integer pHeight) {
81          theNode.setPreferredHeight(pHeight);
82      }
83  
84      @Override
85      public void setBorderPadding(final Integer pPadding) {
86          super.setBorderPadding(pPadding);
87          theNode.createWrapperPane(getBorderTitle(), getBorderPadding());
88      }
89  
90      @Override
91      public void setBorderTitle(final String pTitle) {
92          super.setBorderTitle(pTitle);
93          theNode.createWrapperPane(getBorderTitle(), getBorderPadding());
94      }
95  }