Incorporating HTML with JavaScript in my Java application -
i'm writing small cbt java application. questions read in local mysql database. application dynamically builds question include drop down lists , provides instant feedback on incorrect answers. due java limitations, had resort using html , javascript construct these questions. have jeditorpane have simple html page built in:
string html = ""; try { html+="<html><head></head>"; html+="<body onload='tester()'>"; html+="<div id='stuff'>"; html+="</div>"; html+="</body></html>"; htmlpane.setcontenttype("text/html"); htmlpane.settext(html); } catch(exception e) { e.printstacktrace(); system.out.println("some problem has occured"+e.getmessage()); }
now trying figure out how add associated javascript populate "stuff" div. further, need return results javascript calling java method.
you use nashorn (http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html) javascript engine in java. can run javascript java-code of scriptenginemanager
.
but in cases not best design mix several technologies different languages together. i'm pretty sure can implement in pure java.
you should able implement using flowlayout
in swing (https://docs.oracle.com/javase/tutorial/uiswing/layout/flow.html).
a better solution this; can put combobox, radio button, text field, table on text area?
Comments
Post a Comment