0

I am trying to find some java code that would represent the display of a set of HTML objects (i.e. this code would go in the paint function). This is to go into a home built IDE f ro HTML and javascript (I can't use a ready made version, for complicated reasons)

I can't use images to represent the HTML objects, as the properties (border color, etc) all need to be changeable.

In short, I require the code that could be used in the paint method of a HTML component.

Does anyone have any idea where I could get this? Or an idea of how to do it. I just tried to hand write the code to represent a select tag, and its very difficult.

EDIT: It turns out (as stated below) that what I am looking for is a HTML renderer. However, the code that I have is javascript, that is interpreted as HTML by a browser. The following code is that generated by the IDE, I have a way of accessing the properties that will be required (borderColor, etc) what I require is a way to render these onto a JPanel. i.e. How can I draw a red box onto the JPanel that represents the DIV below (simple example, I can do this, but need the same for a large subset (preferrably all) css properties):

function componentName(constructor, properties){
this.style = {}
this.style.left = 0; //@property TYPE_TEXT left
this.style.top = 0; //@property TYPE_TEXT top
this.style.width = 100; //@property TYPE_TEXT width
this.style.height = 50; //@property TYPE_TEXT height
this.body0 = document.body
this.body0.onmousedown = this.this.body0_onmousedown
this.body0.style.borderStyle = ""
this.body0.style.borderWidth = "0px"
this.body0.style.overflow = "auto"
this.body0.style.top = "0px"
this.body0.style.left = "0px"
this.body0.style.position = "fixed"
this.body0.name = ""
this.body0.style.backgroundColor = "#ffffff"
this.body0.onmousedown = this.body0_onmousedown
this.body0.style.width = "296px"
this.body0.style.height = "193px"
this.DIV0 = document.createElement("DIV")
this.DIV0.style.height = "216px"
this.DIV0.style.width = "181px"
this.DIV0.onmousedown = this.DIV0_onmousedown
this.DIV0.style.top = "40px"
this.DIV0.style.backgroundColor = "#ff0000"
...etc
}

2 Answers 2

1

You can try the Java DOM. For example, there is an Element interface. There are multiple concrete implementations, including IIOMetadataNode

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, but these don't have any paint code method, what I require is a way of graphically representing an element, i.e. an input element, or select element.
@ZackNewsham, are you looking for a Java HTML renderer, or what? That's different from just representing the tag.
yes I think that may have been a better way of describing it, although now an additional "wrinkle" is that the code that is generated is in fact javascript, which browsers convert to HTML... I have edited the question
0

I searched on google for "Java HTML Renderer" and found this: http://lobobrowser.org/cobra.jsp. Maybe that would help? It (from the website) supports HTML4, Javascript, and CSS2.

1 Comment

This looks like it might be good, thanks! I am currently trawling through their code trying to find where the actual painting takes place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.