View Javadoc

1   /*
2    * Copyright 2006-2016 The JGUIraffe Team.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License")
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.jguiraffe.gui.platform.swing.builder.components;
17  
18  import javax.swing.JScrollPane;
19  import javax.swing.JTextArea;
20  
21  /**
22   * <p>
23   * A specific Swing component handler implementation that deals with text area
24   * components.
25   * </p>
26   * <p>
27   * This class inherits most of its functionality from its ancestor, the base
28   * handler class for text components. The main difference to this class is the
29   * fact that a text area is wrapped in a scroll pane.
30   * </p>
31   *
32   * @author Oliver Heger
33   * @version $Id: SwingTextAreaHandler.java 205 2012-01-29 18:29:57Z oheger $
34   */
35  class SwingTextAreaHandler extends SwingTextHandler
36  {
37      /** Stores the scroll pane of the text area. */
38      private final JScrollPane scrollPane;
39  
40      /**
41       * Creates a new instance of {@code SwingTextAreaHandler} and initializes it
42       * with the text area to manage.
43       *
44       * @param textArea the text area
45       * @param scrollWidth the preferred scroll width
46       * @param scrollHeight the preferred scroll height
47       */
48      public SwingTextAreaHandler(JTextArea textArea, int scrollWidth,
49              int scrollHeight)
50      {
51          super(textArea);
52          scrollPane = SwingComponentUtils.scrollPaneFor(textArea, scrollWidth,
53                  scrollHeight);
54      }
55  
56      /**
57       * Returns the outer most component. This is the scroll pane.
58       *
59       * @return the outer component
60       */
61      @Override
62      public Object getOuterComponent()
63      {
64          return scrollPane;
65      }
66  }