6
Bearbeitungen
Ben (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Ben (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
MT4J offers the possibility to integrate Swing Components and thereby enables the user
to include existing applications
To display these components, MT4J provides a SwingTextureRenderer-Object.
In a sample application, the SwingTextureRenderer was added to a MTTextKeyboard as a child
component, PersistentContentPane is a Swing object:
public void addImage(PersistentContentPane cp) {
swing_app = cp;
str = new SwingTextureRenderer(app, swing_app);
str.scheduleRefresh();
final MTImage m = new MTImage(app, str.getTextureToRenderTo());
m.setPositionRelativeToParent(new Vector3D(100, -100, 0));
this.addChild(m);
}
During the evaluation of the SwingTextureRenderer, especially 2 things were of great interest:
# which rendering update frequency is necessary, to provide a smooth user experience, is the
#:performance of SwingTextureRenderers sufficient for that
# how is it possible, to forward MT4J user input to the swing application▼
▲# how is possible, to forward MT4J user input to the swing application
concerning 1.
An update-rate of 150ms has proven to be appropriate, however higher
100ms and even below.
A possible pitfall is the code-location, in which the scheduleRefresh-method of SwingTextureRenderers (str)
public void run() {
swing_app.getEditorWindow().getTextPane().requestFocusInWindow();
queue.postEvent(new KeyEvent(swing_app.getEditorWindow().getTextPane(),
KeyEvent.KEY_TYPED,
Unfortunately, this solution turned out to be a dead end.
The events could't be dispatched/processed by the Swing-component.
A possible way to go, is sending the event
underlying document-object.
|
Bearbeitungen