3

I'm making a game in java. Is there any way I can create HTML widgets for use in the game as the UI? It'd be great if I could attach some event handlers to the controls and fully use CSS, too.

3 Answers 3

2

You can use HTML and CSS for your game, but you'll need a servlet to handle requests.

Event handlers may be written in JavaScript, but they'll ultimately have to communicate with a server on the back end.

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

Comments

1

I know that this doesn't really anwer your question, but there is a library called Amino, that allowes you to use CSS to skin GUI components. That might grant you at least part of your wish.

Comments

1

"If there is a will there is a way"

If you're using raw Java instead of a framework that might give you some ready-made widgets, I believe you'll have to handle the HTML rendering yourself.

In Swing, one would look up class javax.swing.text.html.HTMLEditorKit for understanding how Java's JEditorPane renders basic HTML + CSS (the inner class HTMLFactory is particularly interesting as it creates the views that will render each HTML element). Perhaps this won't help you much, but maybe this would be a starting point.

Stanislav Lapitsky has done of a lot of work in Swing-HTML and gives tools that help you understand how to deal with HTML rendering. Check it out:

http://java-sl.com/about_author.html

Comments

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.