Reputation: 66851
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.
Upvotes: 3
Views: 119
Reputation: 710
"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
Upvotes: 1
Reputation: 17525
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.
Upvotes: 1
Reputation: 308733
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.
Upvotes: 2