pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandro Martini <sandro.mart...@gmail.com>
Subject Re: Error:Application class name is required.
Date Fri, 11 May 2012 10:48:27 GMT

we can start from the HelloBXML (
http://pivot.apache.org/tutorials/hello-bxml.html ), probably it's
not-so-clear explained how to run it as a standalone application (if
possible I'll try to update pages in a few days):

public class HelloBXML implements Application {
note that you could even use this
public class HelloBXML extends Application.Adapter {
and not writing (usually empty methods like suspend and resume, but
this is only a little trick.

In the web page it's written thinking to deploy (consume) it as an Applet.
To execute it as a standalone application (and maybe even as a Web
Start Application), as in any standard Java application, you have to
add the main method like this:

    public static void main(String[] args) {
        DesktopApplicationContext.main(HelloBXML.class, args);

without the main you are able to run it (using the Pivot Eclipse
Plugin) but as a "Pivot Application", because in this case is executed
the class org.apache.pivot.wtk.ScriptApplication , and you have to
give it (the pivot eclipse plugin does it for you) the src argument
with the (source relative) folder containing your class implementing
Application, so for example you could execute this:


in eclipse you have this as launch configuration:
main class: org.apache.pivot.wtk.DesktopApplicationContext
program arguments: org.apache.pivot.wtk.ScriptApplication

Best practices (at least mine) are to use ScriptApplication only for
very simple application, and it's really useful for example to execute
applications made with only bxml files, but in this case note that
only bxml files that have as a main content a Window (or a Frame).

Finally, ScriptApplication handle even other arguments, for example
resources and stylesheet, useful in some cases ...

Note that for many other samples (and our Test Applications, there are
many inside the tests subproject, always useful :-) ...

> I am wondering if I load the window bxml file with the following statements
>      BXMLSerializer bxmlSerializer = new BXMLSerializer();
>      window = (Window)bxmlSerializer.readObject(HelloBXML.class, "Hello.bxml");
> How can I interact with the components defined in the bxml file?
> such as: there is a PushButton whose bxml:id is "pushbutton".
> I want to write the function Buttonpressedlistener() in the java application.what should
I do?
Note that in some cases it's even simpler to define/use them inside bxml files.
Of course it's possible to define/use them in Java (and Scala, Groovy,
etc) sources, but we have to jump to another tutorial:

But for example looking at another usual Pivot Sample, KitchenSink,
you can find that:

                helpAboutMenuItem  =

and then the button press listener is defined for it as follows
ButtonPressListener() {
                    public void buttonPressed(Button button) {

and finally, all elements are setup with call from the usual startup method
    public void startup(Display display, Map<String, String>
properties) throws Exception {

> I know if the class implements bindable,I can use
>      pushButton = (PushButton)namespace.get("pushButton");
you can do this even without bindable (so no need to put this inside
an initialize method), because it's BXMLSerializer that retrieve
elements with the bxml:id attribute

> But now the question is I cant get the java file written like this run as a java desktop
application.when I run it,I get the error:Application class name is required.
as written before, a simpler way is to add the main method

Tell us if you need more info.


View raw message