What's Java Hybrid - Applet + Application?
Asked Answered
W

2

5

And how can I write one?

From comments to my reply, this followed:

"What we had in the old days - An Applet and Application - is not available anymore."

And a rebuttal:

Rubbish. It [An Applet and Application] is called an hybrid, and is alive and well. Ask on a separate question if you would like clarification.

I would like to ask what this Java Hybrid is?

I have searched but for some reason can't find any useful information for something that is "alive and well". The keywords I used maybe slightly off so that could be a reason.

Wenwenceslaus answered 16/9, 2012 at 19:14 Comment(3)
I never heard that term, probably author's own. IMO it's quite general and could be anything - e.g. Java + Java FX.Tonsillotomy
For example.Locution
How does that work? You have init and main in it, why no conflict? Where are the other life cycle methods?Wenwenceslaus
L
16

A hybrid applet/application simply abstracts the initialization of two top-level containers, JFrame and JApplet. Examples are seen here, here and here.

Addendum: How does that work?

  • The first example exposes a factory method, createGUI(), and it adds the returned panel to the extant top-level container.
  • The second provides a static initContainer() method, passing the enclosing top-level container as a parameter.
  • The third creates a class Hybrid that has a static fireup() method and a WindowListener for error reporting.
Locution answered 16/9, 2012 at 19:22 Comment(3)
+1 I was going to offer an answer, but this about covers it (far better than I would have).Rahel
@AndrewThompson I was pretty much waiting for you. But since this covers it and the links do help. I will accept it thanks.Wenwenceslaus
For convenient appletviewer testing, add the <applet /> tag as a comment, as shown here.Locution
P
4

A Java hybrid application is one that can be run as either an application or applet. The main application class is derived from either java.awt.Applet or javax.swing.JApplet.

As the main method is the entry point when running in application 'mode', it will not be called by the applet container.

The method

public void init()

is called automatically by the applet container but must be manually called from the main method (when running as an application).

Pulvinate answered 16/9, 2012 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.