예제 #1
0
        /// <summary>
        /// Adds the specified component to this scroll pane container.
        /// If the scroll pane has an existing child component, that
        /// component is removed and the new one is added. </summary>
        /// <param name="comp"> the component to be added </param>
        /// <param name="constraints">  not applicable </param>
        /// <param name="index"> position of child component (must be &lt;= 0) </param>
        protected internal sealed override void AddImpl(Component comp, Object constraints, int index)
        {
            lock (TreeLock)
            {
                if (ComponentCount > 0)
                {
                    Remove(0);
                }
                if (index > 0)
                {
                    throw new IllegalArgumentException("position greater than 0");
                }

                if (!SunToolkit.isLightweightOrUnknown(comp))
                {
                    base.AddImpl(comp, constraints, index);
                }
                else
                {
                    AddToPanel(comp, constraints, index);
                }
            }
        }