Class JSComponent

    • Constructor Summary

      Constructors 
      Constructor Description
      JSComponent​(def.dom.HTMLElement element)
      Creates the object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChildEventListenerByQuery​(java.lang.String query, java.lang.String event, def.dom.EventListener listener)
      Adds an event listener to a child of the HTML element
      void addEventListener​(java.lang.String event, def.dom.EventListener listener)
      Adds an event listener
      void appendChild​(JSComponent component)
      Adds a child to the HTML element
      void appendChildInTree​(java.lang.String query, JSComponent component)
      Adds a child to the HTML element
      void appendInBody()
      Adds the HTML element to the BODY element
      void appendNodeChild​(def.dom.Node node)
      Adds a child to the HTML element
      void appendNodeChildInTree​(java.lang.String query, def.dom.Node node)
      Adds a child to the HTML element
      void clearChildContentByQuery​(java.lang.String query)
      Clears the text content of a child of the HTML element
      void clearContent()
      Clears the text content of the HTML element
      void cssAddClass​(java.lang.String cl)
      Adds a CSS class to the class list of the HTML element
      def.dom.DOMTokenList cssClassList()
      Returns the class list of the HTML element
      void cssRemoveClass​(java.lang.String cl)
      Removes a CSS class from the class list of the HTML element
      void cssToggleClass​(java.lang.String cl)
      Toggles a CSS class in the class list of the HTML element (if the class is set removes it, otherwise adds it)
      java.lang.String getAttribute​(java.lang.String key)
      Returns an attribute of the HTML element (for example value is a property, readonly is an attribute)
      java.lang.String getChildAttributeByIndex​(int index, java.lang.String key)
      Returns an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
      java.lang.String getChildAttributeByQuery​(java.lang.String query, java.lang.String key)
      Returns an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
      double getChildCount()
      Returns the child count of the HTML element
      java.lang.String getChildPropertyByQuery​(java.lang.String query, java.lang.String key)
      Returns a property of a child of the HTML element (for example value is a property, readonly is an attribute)
      def.dom.CSSStyleDeclaration getChilStyleByIndex​(int index)
      Returns the style of a child of the HTML element
      def.dom.CSSStyleDeclaration getChilStyleByQuery​(java.lang.String query)
      Returns the style of a child of the HTML element
      java.lang.String getID()
      Returns the ID of the HTML element
      java.lang.String getProperty​(java.lang.String key)
      Returns a property of the HTML element (for example value is a property, readonly is an attribute)
      def.dom.CSSStyleDeclaration getStyle()
      Returns the style of the HTML element
      void insertBefore​(JSComponent component, java.lang.String query)
      insert a child to the HTML element before another child
      void insertBeforeInTree​(java.lang.String queryInTree, JSComponent component, java.lang.String query)
      insert a child to the HTML element before another child
      void insertNodeBefore​(def.dom.Node node, java.lang.String query)
      insert a child to the HTML element before another child
      void insertNodeBeforeInTree​(java.lang.String queryInTree, def.dom.Node node, java.lang.String query)
      insert a child to the HTML element before another child
      <T> T invoke​(java.lang.String method)
      Invokes a method of the HTML element
      <T> T invokeInTree​(java.lang.String query, java.lang.String method)
      Invokes a method of an child of the HTML element
      void prependChild​(JSComponent component)
      Prepends a child to the HTML element
      void prependChildInTree​(java.lang.String query, JSComponent component)
      Prepends a child to the HTML element
      void prependNodeChild​(def.dom.Node node)
      Prepends a child to the HTML element
      void prependNodeChildInTree​(java.lang.String query, def.dom.Node node)
      Prepends a child to the HTML element
      void removeAttribute​(java.lang.String key)
      Removes an attribute of the HTML element (for example value is a property, readonly is an attribute)
      void removeChildAttributeByQuery​(java.lang.String query, java.lang.String key)
      Removes an attribute of a child the HTML element (for example value is a property, readonly is an attribute)
      void removeFromBody()
      Removes the HTML element from the BODY element
      void setAttribute​(java.lang.String key, java.lang.String value)
      Sets an attribute of the HTML element (for example value is a property, readonly is an attribute)
      void setBackground​(Color color)
      Clone of javax.swing.JComponent.setBackground
      void setChildAttributeByIndex​(int index, java.lang.String key, java.lang.String value)
      Sets an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
      void setChildAttributeByQuery​(java.lang.String query, java.lang.String key, java.lang.String value)
      Sets an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
      void setChildPropertyByQuery​(java.lang.String query, java.lang.String key, java.lang.String value)
      Sets a property of a child of the HTML element (for example value is a property, readonly is an attribute)
      void setContent​(java.lang.String content)
      Sets the text content of the HTML element
      void setEnabled​(boolean b)
      Clone of javax.swing.JComponent.setEnabled
      void setID​(java.lang.String id)
      Sets the ID of the HTML element
      void setProperty​(java.lang.String key, java.lang.String value)
      Sets a property of the HTML element (for example value is a property, readonly is an attribute)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSComponent

        public JSComponent​(def.dom.HTMLElement element)
        Creates the object
        Parameters:
        element - The HTML element representing this component
    • Method Detail

      • setBackground

        public void setBackground​(Color color)
        Clone of javax.swing.JComponent.setBackground
        Parameters:
        color - The color
      • setEnabled

        public void setEnabled​(boolean b)
        Clone of javax.swing.JComponent.setEnabled
        Parameters:
        b - true to enable the button, false otherwise
      • invoke

        public <T> T invoke​(java.lang.String method)
        Invokes a method of the HTML element
        Type Parameters:
        T - The type of the return value
        Parameters:
        method - The method name (with parenthesis)
        Returns:
        The return value of the method
      • invokeInTree

        public <T> T invokeInTree​(java.lang.String query,
                                  java.lang.String method)
        Invokes a method of an child of the HTML element
        Type Parameters:
        T - The type of the return value
        Parameters:
        query - The query selector
        method - The method name (with parenthesis)
        Returns:
        The return value of the method
      • setID

        public void setID​(java.lang.String id)
        Sets the ID of the HTML element
        Parameters:
        id - The ID of the HTML element
      • getID

        public java.lang.String getID()
        Returns the ID of the HTML element
        Returns:
        The ID of the HTML element
      • cssAddClass

        public void cssAddClass​(java.lang.String cl)
        Adds a CSS class to the class list of the HTML element
        Parameters:
        cl - The class to add
      • cssRemoveClass

        public void cssRemoveClass​(java.lang.String cl)
        Removes a CSS class from the class list of the HTML element
        Parameters:
        cl - The class to remove
      • cssToggleClass

        public void cssToggleClass​(java.lang.String cl)
        Toggles a CSS class in the class list of the HTML element (if the class is set removes it, otherwise adds it)
        Parameters:
        cl - The class to toggle
      • cssClassList

        public def.dom.DOMTokenList cssClassList()
        Returns the class list of the HTML element
        Returns:
        The class list of the HTML element
      • getStyle

        public def.dom.CSSStyleDeclaration getStyle()
        Returns the style of the HTML element
        Returns:
        The style of the HTML element
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.String value)
        Sets a property of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        key - the property key
        value - The property value
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Returns a property of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        key - The property key
        Returns:
        The property value
      • setAttribute

        public void setAttribute​(java.lang.String key,
                                 java.lang.String value)
        Sets an attribute of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        key - The attribute key
        value - The attribute value
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String key)
        Returns an attribute of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        key - The attribute key
        Returns:
        The attribute value
      • removeAttribute

        public void removeAttribute​(java.lang.String key)
        Removes an attribute of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        key - The attribute key
      • clearContent

        public void clearContent()
        Clears the text content of the HTML element
      • setContent

        public void setContent​(java.lang.String content)
        Sets the text content of the HTML element
        Parameters:
        content - The text content of this component
      • addEventListener

        public void addEventListener​(java.lang.String event,
                                     def.dom.EventListener listener)
        Adds an event listener
        Parameters:
        event - The event
        listener - The listener
      • appendInBody

        public void appendInBody()
        Adds the HTML element to the BODY element
      • removeFromBody

        public void removeFromBody()
        Removes the HTML element from the BODY element
      • appendChild

        public void appendChild​(JSComponent component)
        Adds a child to the HTML element
        Parameters:
        component - The child component
      • appendNodeChild

        public void appendNodeChild​(def.dom.Node node)
        Adds a child to the HTML element
        Parameters:
        node - The node
      • insertBefore

        public void insertBefore​(JSComponent component,
                                 java.lang.String query)
        insert a child to the HTML element before another child
        Parameters:
        component - The child component
        query - The query selector
      • insertNodeBefore

        public void insertNodeBefore​(def.dom.Node node,
                                     java.lang.String query)
        insert a child to the HTML element before another child
        Parameters:
        node - The node
        query - The query selector
      • prependChild

        public void prependChild​(JSComponent component)
        Prepends a child to the HTML element
        Parameters:
        component - The child component
      • prependNodeChild

        public void prependNodeChild​(def.dom.Node node)
        Prepends a child to the HTML element
        Parameters:
        node - The node
      • appendChildInTree

        public void appendChildInTree​(java.lang.String query,
                                      JSComponent component)
        Adds a child to the HTML element
        Parameters:
        query - The query selector
        component - The child component
      • appendNodeChildInTree

        public void appendNodeChildInTree​(java.lang.String query,
                                          def.dom.Node node)
        Adds a child to the HTML element
        Parameters:
        query - The query selector
        node - The node
      • insertBeforeInTree

        public void insertBeforeInTree​(java.lang.String queryInTree,
                                       JSComponent component,
                                       java.lang.String query)
        insert a child to the HTML element before another child
        Parameters:
        queryInTree - The query selector in tree
        component - The child component
        query - The query selector
      • insertNodeBeforeInTree

        public void insertNodeBeforeInTree​(java.lang.String queryInTree,
                                           def.dom.Node node,
                                           java.lang.String query)
        insert a child to the HTML element before another child
        Parameters:
        queryInTree - The query selector in tree
        node - The node
        query - The query selector
      • prependChildInTree

        public void prependChildInTree​(java.lang.String query,
                                       JSComponent component)
        Prepends a child to the HTML element
        Parameters:
        query - The query selector
        component - The child component
      • prependNodeChildInTree

        public void prependNodeChildInTree​(java.lang.String query,
                                           def.dom.Node node)
        Prepends a child to the HTML element
        Parameters:
        query - The query selector
        node - The node
      • getChilStyleByIndex

        public def.dom.CSSStyleDeclaration getChilStyleByIndex​(int index)
        Returns the style of a child of the HTML element
        Parameters:
        index - The child index
        Returns:
        The style of a child of the HTML element
      • getChilStyleByQuery

        public def.dom.CSSStyleDeclaration getChilStyleByQuery​(java.lang.String query)
        Returns the style of a child of the HTML element
        Parameters:
        query - The query selector
        Returns:
        The style of a child of the HTML element
      • getChildPropertyByQuery

        public java.lang.String getChildPropertyByQuery​(java.lang.String query,
                                                        java.lang.String key)
        Returns a property of a child of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        query - The query selector
        key - The property key
        Returns:
        The property value
      • setChildPropertyByQuery

        public void setChildPropertyByQuery​(java.lang.String query,
                                            java.lang.String key,
                                            java.lang.String value)
        Sets a property of a child of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        query - The query selector
        key - The property key
        value - The property value
      • setChildAttributeByIndex

        public void setChildAttributeByIndex​(int index,
                                             java.lang.String key,
                                             java.lang.String value)
        Sets an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        index - The child index
        key - The attribute key
        value - The attribute value
      • setChildAttributeByQuery

        public void setChildAttributeByQuery​(java.lang.String query,
                                             java.lang.String key,
                                             java.lang.String value)
        Sets an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        query - The query selector
        key - The attribute key
        value - The attribute value
      • getChildAttributeByIndex

        public java.lang.String getChildAttributeByIndex​(int index,
                                                         java.lang.String key)
        Returns an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        index - The child index
        key - The attribute key
        Returns:
        The attribute value
      • getChildAttributeByQuery

        public java.lang.String getChildAttributeByQuery​(java.lang.String query,
                                                         java.lang.String key)
        Returns an attribute of a child of the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        query - The query selector
        key - The attribute key
        Returns:
        The attribute value
      • removeChildAttributeByQuery

        public void removeChildAttributeByQuery​(java.lang.String query,
                                                java.lang.String key)
        Removes an attribute of a child the HTML element (for example value is a property, readonly is an attribute)
        Parameters:
        query - The query selector
        key - The attribute key
      • clearChildContentByQuery

        public void clearChildContentByQuery​(java.lang.String query)
        Clears the text content of a child of the HTML element
        Parameters:
        query - The query selector
      • addChildEventListenerByQuery

        public void addChildEventListenerByQuery​(java.lang.String query,
                                                 java.lang.String event,
                                                 def.dom.EventListener listener)
        Adds an event listener to a child of the HTML element
        Parameters:
        query - The query selector
        event - The event
        listener - The listener
      • getChildCount

        public double getChildCount()
        Returns the child count of the HTML element
        Returns:
        The child count of the HTML element