예제 #1
0
        /// <summary>
        /// Reads default serializable fields to stream. </summary>
        /// <exception cref="HeadlessException"> if
        /// <code>GraphicsEnvironment.isHeadless()</code> returns
        /// <code>true</code> </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException, HeadlessException
        private void ReadObject(ObjectInputStream s)
        {
            GraphicsEnvironment.CheckHeadless();
            // 4352819: Gotcha!  Cannot use s.defaultReadObject here and
            // then continue with reading optional data.  Use GetField instead.
            ObjectInputStream.GetField f = s.ReadFields();

            // Old fields
            ScrollbarDisplayPolicy_Renamed = f.Get("scrollbarDisplayPolicy", SCROLLBARS_AS_NEEDED);
            HAdjustable_Renamed            = (ScrollPaneAdjustable)f.Get("hAdjustable", null);
            VAdjustable_Renamed            = (ScrollPaneAdjustable)f.Get("vAdjustable", null);

            // Since 1.4
            WheelScrollingEnabled_Renamed = f.Get("wheelScrollingEnabled", DefaultWheelScroll);

            //      // Note to future maintainers
            //      if (f.defaulted("wheelScrollingEnabled")) {
            //          // We are reading pre-1.4 stream that doesn't have
            //          // optional data, not even the TC_ENDBLOCKDATA marker.
            //          // Reading anything after this point is unsafe as we will
            //          // read unrelated objects further down the stream (4352819).
            //      }
            //      else {
            //          // Reading data from 1.4 or later, it's ok to try to read
            //          // optional data as OptionalDataException with eof == true
            //          // will be correctly reported
            //      }
        }
예제 #2
0
        /// <summary>
        /// Reads the menu component from an object input stream.
        /// </summary>
        /// <param name="s"> the <code>ObjectInputStream</code> to read </param>
        /// <exception cref="HeadlessException"> if
        ///   <code>GraphicsEnvironment.isHeadless</code> returns
        ///   <code>true</code>
        /// @serial </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException, HeadlessException
        private void ReadObject(ObjectInputStream s)
        {
            GraphicsEnvironment.CheckHeadless();

            Acc = AccessController.Context;

            s.DefaultReadObject();

            AppContext = AppContext.AppContext;
        }
예제 #3
0
        /// <summary>
        /// Constructs a Checkbox with the specified label, set to the
        /// specified state, and in the specified check box group.
        /// </summary>
        /// <param name="label">   a string label for this check box,
        ///                        or <code>null</code> for no label. </param>
        /// <param name="state">   the initial state of this check box. </param>
        /// <param name="group">   a check box group for this check box,
        ///                           or <code>null</code> for no group. </param>
        /// <exception cref="HeadlessException"> if
        ///     <code>GraphicsEnvironment.isHeadless</code>
        ///     returns <code>true</code> </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless
        /// @since     JDK1.1 </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Checkbox(String label, boolean state, CheckboxGroup group) throws HeadlessException
        public Checkbox(String label, bool state, CheckboxGroup group)
        {
            GraphicsEnvironment.CheckHeadless();
            this.Label_Renamed = label;
            this.State_Renamed = state;
            this.Group         = group;
            if (state && (group != null))
            {
                group.SelectedCheckbox = this;
            }
        }
예제 #4
0
        /// <summary>
        /// Create a new scrollpane container. </summary>
        /// <param name="scrollbarDisplayPolicy"> policy for when scrollbars should be shown </param>
        /// <exception cref="IllegalArgumentException"> if the specified scrollbar
        ///     display policy is invalid </exception>
        /// <exception cref="HeadlessException"> if GraphicsEnvironment.isHeadless()
        ///     returns true </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ConstructorProperties({"scrollbarDisplayPolicy"}) public ScrollPane(int scrollbarDisplayPolicy) throws HeadlessException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public ScrollPane(int scrollbarDisplayPolicy)
        {
            GraphicsEnvironment.CheckHeadless();
            this.LayoutMgr      = null;
            this.Width_Renamed  = 100;
            this.Height_Renamed = 100;
            switch (scrollbarDisplayPolicy)
            {
            case SCROLLBARS_NEVER:
            case SCROLLBARS_AS_NEEDED:
            case SCROLLBARS_ALWAYS:
                this.ScrollbarDisplayPolicy_Renamed = scrollbarDisplayPolicy;
                break;

            default:
                throw new IllegalArgumentException("illegal scrollbar display policy");
            }

            VAdjustable_Renamed   = new ScrollPaneAdjustable(this, new PeerFixer(this, this), Adjustable_Fields.VERTICAL);
            HAdjustable_Renamed   = new ScrollPaneAdjustable(this, new PeerFixer(this, this), Adjustable_Fields.HORIZONTAL);
            WheelScrollingEnabled = DefaultWheelScroll;
        }
예제 #5
0
        /// <summary>
        /// Reads the <code>ObjectInputStream</code> and if it
        /// isn't <code>null</code> adds a listener to receive
        /// item events fired by the <code>Checkbox</code>.
        /// Unrecognized keys or values will be ignored.
        /// </summary>
        /// <param name="s"> the <code>ObjectInputStream</code> to read </param>
        /// <exception cref="HeadlessException"> if
        ///   <code>GraphicsEnvironment.isHeadless</code> returns
        ///   <code>true</code>
        /// @serial </exception>
        /// <seealso cref= #removeItemListener(ItemListener) </seealso>
        /// <seealso cref= #addItemListener(ItemListener) </seealso>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
        /// <seealso cref= #writeObject(ObjectOutputStream) </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException, HeadlessException
        private void ReadObject(ObjectInputStream s)
        {
            GraphicsEnvironment.CheckHeadless();
            s.DefaultReadObject();

            Object keyOrNull;

            while (null != (keyOrNull = s.ReadObject()))
            {
                String key = ((String)keyOrNull).intern();

                if (ItemListenerK == key)
                {
                    AddItemListener((ItemListener)(s.ReadObject()));
                }

                else         // skip value for unrecognized key
                {
                    s.ReadObject();
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Creates a <code>MenuComponent</code>. </summary>
        /// <exception cref="HeadlessException"> if
        ///    <code>GraphicsEnvironment.isHeadless</code>
        ///    returns <code>true</code> </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public MenuComponent() throws HeadlessException
        public MenuComponent()
        {
            GraphicsEnvironment.CheckHeadless();
            AppContext = AppContext.AppContext;
        }
예제 #7
0
        /// <summary>
        /// Constructs a button with the specified label.
        /// </summary>
        /// <param name="label">  a string label for the button, or
        ///               <code>null</code> for no label </param>
        /// <exception cref="HeadlessException"> if GraphicsEnvironment.isHeadless()
        /// returns true </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Button(String label) throws HeadlessException
        public Button(String label)
        {
            GraphicsEnvironment.CheckHeadless();
            this.Label_Renamed = label;
        }
예제 #8
0
        public static Cursor GetSystemCustomCursor(String name)
        {
            GraphicsEnvironment.CheckHeadless();
            Cursor cursor = SystemCustomCursors[name];

            if (cursor == null)
            {
                lock (SystemCustomCursors)
                {
                    if (SystemCustomCursorProperties == null)
                    {
                        LoadSystemCustomCursorProperties();
                    }
                }

                String prefix = CursorDotPrefix + name;
                String key    = prefix + DotFileSuffix;

                if (!SystemCustomCursorProperties.ContainsKey(key))
                {
                    if (Log.isLoggable(PlatformLogger.Level.FINER))
                    {
                        Log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
                    }
                    return(null);
                }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String fileName = systemCustomCursorProperties.getProperty(key);
                String fileName = SystemCustomCursorProperties.GetProperty(key);

                String localized = SystemCustomCursorProperties.GetProperty(prefix + DotNameSuffix);

                if (localized == null)
                {
                    localized = name;
                }

                String hotspot = SystemCustomCursorProperties.GetProperty(prefix + DotHotspotSuffix);

                if (hotspot == null)
                {
                    throw new AWTException("no hotspot property defined for cursor: " + name);
                }

                StringTokenizer st = new StringTokenizer(hotspot, ",");

                if (st.CountTokens() != 2)
                {
                    throw new AWTException("failed to parse hotspot property for cursor: " + name);
                }

                int x = 0;
                int y = 0;

                try
                {
                    x = Convert.ToInt32(st.NextToken());
                    y = Convert.ToInt32(st.NextToken());
                }
                catch (NumberFormatException)
                {
                    throw new AWTException("failed to parse hotspot property for cursor: " + name);
                }

                try
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int fx = x;
                    int fx = x;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int fy = y;
                    int fy = y;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String flocalized = localized;
                    String flocalized = localized;

                    cursor = AccessController.doPrivileged <Cursor>(new PrivilegedExceptionActionAnonymousInnerClassHelper(fileName, fx, fy, flocalized));
                }
                catch (Exception e)
                {
                    throw new AWTException("Exception: " + e.GetType() + " " + e.Message + " occurred while creating cursor " + name);
                }

                if (cursor == null)
                {
                    if (Log.isLoggable(PlatformLogger.Level.FINER))
                    {
                        Log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
                    }
                }
                else
                {
                    SystemCustomCursors[name] = cursor;
                }
            }

            return(cursor);
        }
예제 #9
0
        /// <summary>
        /// Creates a new choice menu. The menu initially has no items in it.
        /// <para>
        /// By default, the first item added to the choice menu becomes the
        /// selected item, until a different selection is made by the user
        /// by calling one of the <code>select</code> methods.
        /// </para>
        /// </summary>
        /// <exception cref="HeadlessException"> if GraphicsEnvironment.isHeadless()
        /// returns true </exception>
        /// <seealso cref=       java.awt.GraphicsEnvironment#isHeadless </seealso>
        /// <seealso cref=       #select(int) </seealso>
        /// <seealso cref=       #select(java.lang.String) </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Choice() throws HeadlessException
        public Choice()
        {
            GraphicsEnvironment.CheckHeadless();
            PItems = new Vector <>();
        }
예제 #10
0
        /// <summary>
        /// Read a label from an object input stream. </summary>
        /// <exception cref="HeadlessException"> if
        /// <code>GraphicsEnvironment.isHeadless()</code> returns
        /// <code>true</code>
        /// @serial
        /// @since 1.4 </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException, HeadlessException
        private void ReadObject(ObjectInputStream s)
        {
            GraphicsEnvironment.CheckHeadless();
            s.DefaultReadObject();
        }
예제 #11
0
        /// <summary>
        /// Constructs a new label that presents the specified string of
        /// text with the specified alignment.
        /// Possible values for <code>alignment</code> are <code>Label.LEFT</code>,
        /// <code>Label.RIGHT</code>, and <code>Label.CENTER</code>. </summary>
        /// <param name="text"> the string that the label presents.
        ///        A <code>null</code> value
        ///        will be accepted without causing a NullPointerException
        ///        to be thrown. </param>
        /// <param name="alignment">   the alignment value. </param>
        /// <exception cref="HeadlessException"> if GraphicsEnvironment.isHeadless()
        /// returns true. </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Label(String text, int alignment) throws HeadlessException
        public Label(String text, int alignment)
        {
            GraphicsEnvironment.CheckHeadless();
            this.Text_Renamed = text;
            Alignment         = alignment;
        }