Best strategy to migrate a java applet?
Added by welton nascimento over 9 years ago
Hi.
Chrome is dropping out java applet support next month and I'm looking for viable alternative for a drawing applet we have here.
I took a look at figtree, but couldn't understand it very well.
My applet is a JPanel (as all applets are, I guess), with three JPanels and several subcomponents. As I said, is a specialized drawing app.
Right now, I was able to follow (or try to) figtree approach, creating a WPaintedWidget,
public class CroquiWebApplication extends WApplication{
public CroquiWebApplication(WEnvironment env) {
super(env);
setTitle("Croqui Test");
WVBoxLayout layout = new WVBoxLayout(getRoot());
layout.addWidget(new CroquiWidget());
}
}
public class CroquiWidget extends WPaintedWidget {
private MeuCroqui croqui;
private WebGraphics2D graphics = new WebGraphics2D(new WPainter());
public CroquiWidget(){
croqui = new MeuCroqui(){
private static final long serialVersionID = 1L;
@Override
public void repaint() {
CroquiWidget.this.update();
}
@Override
public Graphics getGraphics() {
return graphics;
}
};
// this stub is needed to emulate the browser environment, as passing <applet> tag parameters to the applet.
croqui.setStub(new MyAppletStub());
// this is where the applet really runs.
// croqui.init() is this:
// public void init() {
//
// //Take lots of parameters from emulated <applet> tag
// Dados dados = new Dados();
// Container container = this.getContentPane();
// container.setLayout(new GridBagLayout());
// GridBagConstraints c = new GridBagConstraints();
// c.ipady = 0;
// c.anchor = 10;
// this.panelDesenho = new PanelDesenho(dados);
// JPanel painel = new JPanel(new BorderLayout());
// painel.setMaximumSize(new Dimension(950, 592));
// painel.setMinimumSize(new Dimension(950, 592));
// painel.setPreferredSize(new Dimension(950, 592));
// painel.add(this.panelDesenho, "Center");
// this.panelFerramentasInferior = new PanelFerramentasInferior(dados, this.panelDesenho);
// painel.add(this.panelFerramentasInferior, "South");
// this.panelFerramentasLateral = new PanelFerramentasLateral(dados, this.panelDesenho, this.panelFerramentasInferior);
// painel.add(this.panelFerramentasLateral, "East");
// container.add(painel, c);
// }
croqui.init();
}
@Override
protected void paintEvent(WPaintDevice wPaintDevice) {
WPainter wPainter = new WPainter(wPaintDevice);
WebGraphics2D webGraphics2D = new WebGraphics2D(wPainter);
croqui.paint(webGraphics2D);
}
@Override
protected void layoutSizeChanged(int width, int height) {
super.layoutSizeChanged(width, height);
croqui.setSize(width, height);
}
}
Right now, I am getting a blank screen and no errors on jetty console. As far as I can tell, by remote debugging it, the code is running just fine. It just is not being rendered, I think, or the panels are not being resized to the screen size.
QUESTIONS:
1 - I can embed a this Applet inside a JFrame just fine, but I have to call Jframe.pack() and setVisible(true) to get things displayed. Shouldn't I set WApplication size? Or WPaintedWidget?
2 - I couldn't figure out how the applet is embedded inside the WPaintedWidget. When using a JFrame, I have to JFrame.add() it.
3 - Is it even possible? :)
Thanks for any help.
Captura de Tela 2015-08-18 às 21.04.02.png (67.1 KB) Captura de Tela 2015-08-18 às 21.04.02.png | Screen Capture |
Replies (1)
RE: Best strategy to migrate a java applet? - Added by Koen Deforche over 9 years ago
Hey,
You'll only be able to recycle the painted part of your applet to integrate it into a WPaintedWidget, but will need to recreate the rest of of the UI using Wt widgets.
Koen