You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Luiz Gustavo <lu...@gmail.com> on 2010/12/18 16:39:36 UTC

BXML doubt

Hi,

I'm writing an application, and I'm facing problems to meka a frame stay in
front of a Window. I'm following the examples in the tutorial, specifically
that one related to Window.
I still can not understand what is exactly the relation between the bxml
file and the base class passed to the BXMLSerializer.readObject method. I'll
show what Im doing:

I have a main class, the entry point to my application:

public class Main implements Application {

  private Display display = null;
  private Window window = null;
  BXMLSerializer bxmlSerializer;
  public static final String LANGUAGE_KEY = "language";

...


public Main(){


    Action.getNamedActions().put("abrirCategorias", new Action() {
      @Override
      public void perform(Component source) {
          try {
            Categoria categoria = (Categoria)
bxmlSerializer.readObject(Categoria.class, "categoria.bxml");
            categoria.open(display);
          }
          catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          catch (SerializationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
      }
    });


    }
    ...


}

Among other Actions, I have that one defined in the construtor, that is used
to open a frame in front of my main Window.
The case, as I said before, is that when this action is fired, the frame
stay behind the main window.

This is the Class used for the frame (this is still quite simple):


public class Categoria extends Frame implements Bindable {

  private TextInput descricao;


  @Override
  public void initialize(Map<String, Object> arg0, URL arg1, Resources arg2)
{
    // TODO Auto-generated method stub

  }
}


and this is the BXML file:


<jm:Categoria icon="@application_form.png" title="Categorias"
    xmlns:bxml="http://pivot.apache.org/bxml"
    xmlns:content="org.apache.pivot.wtk.content"
    xmlns="org.apache.pivot.wtk"
    xmlns:jm="jm.pivot.app.controle" maximized="false"
    styles="{padding:{top:0, left:4, bottom:4, right:4},
showWindowControls:true}">


    <Border styles="{backgroundColor:null, padding:2}">
        <BoxPane>
            <Label text="Descricao:"/>
            <TextInput bxml:id="descricao"/>
        </BoxPane>
    </Border>

</jm:Categoria>


Now, I'd like to undestand if I'm doing the right thing, passing the
Categoria.class in the readObject method, since Categoria class implements
Bindable.

How can i make Categoria Frame stay in front of Window?


Thanks in advance!

Re: BXML doubt

Posted by Luiz Gustavo <lu...@gmail.com>.
Hi Greg!


thanks for the explanation. I understood the relation between Bindable
classes and their bxml files, and the application is becoming fine =)

Cheers,

Luiz Gustavo


2010/12/18 Greg Brown <gk...@verizon.net>

> > I could open the frame on top of the Window as you said. But I still
> didn't understood how do I say that Categoria class is the class related to
> the categoria.bxml file. Just using <jm:Categoria as the root element in the
> bxml file grants me that?
>
> Yes. Where you say:
>
> <jm:Categoria .../>
>
> you are actually creating an instance of jm.pivot.app.controle.Categoria,
> since the "jm" namespace prefix is mapped to the jm.pivot.app.controle
> package.
>
> Because it implements Bindable, BXMLSerializer will call initialize() on it
> once the BXML file has been completely processed.
>
> G
>
>
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Re: BXML doubt

Posted by Greg Brown <gk...@verizon.net>.
> I could open the frame on top of the Window as you said. But I still didn't understood how do I say that Categoria class is the class related to the categoria.bxml file. Just using <jm:Categoria as the root element in the bxml file grants me that?

Yes. Where you say:

<jm:Categoria .../>

you are actually creating an instance of jm.pivot.app.controle.Categoria, since the "jm" namespace prefix is mapped to the jm.pivot.app.controle package.

Because it implements Bindable, BXMLSerializer will call initialize() on it once the BXML file has been completely processed.

G




Re: BXML doubt

Posted by Luiz Gustavo <lu...@gmail.com>.
Hi Greg,

I could open the frame on top of the Window as you said. But I still didn't
understood how do I say that Categoria class is the class related to the
categoria.bxml file. Just using <jm:Categoria as the root element in the
bxml file grants me that?


Thanks

Luiz Gustavo


2010/12/18 Greg Brown <gk...@verizon.net>

> I understand your confusion. That particular overload of readObject() is
> not especially clear. The class argument basically just identifies the name
> of the resource bundle - it has nothing to do with Bindable.
>
> Your BXML looks fine - to make the frame stay on top of the window, you
> just need to open the frame with the window as its owner.
>
>
> On Dec 18, 2010, at 10:39 AM, Luiz Gustavo wrote:
>
> Hi,
>
> I'm writing an application, and I'm facing problems to meka a frame stay in
> front of a Window. I'm following the examples in the tutorial, specifically
> that one related to Window.
> I still can not understand what is exactly the relation between the bxml
> file and the base class passed to the BXMLSerializer.readObject method. I'll
> show what Im doing:
>
> I have a main class, the entry point to my application:
>
> public class Main implements Application {
>
>   private Display display = null;
>   private Window window = null;
>   BXMLSerializer bxmlSerializer;
>   public static final String LANGUAGE_KEY = "language";
>
> ...
>
>
> public Main(){
>
>
>     Action.getNamedActions().put("abrirCategorias", new Action() {
>       @Override
>       public void perform(Component source) {
>           try {
>             Categoria categoria = (Categoria)
> bxmlSerializer.readObject(Categoria.class, "categoria.bxml");
>             categoria.open(display);
>           }
>           catch (IOException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>           }
>           catch (SerializationException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>           }
>       }
>     });
>
>
>     }
>     ...
>
>
> }
>
> Among other Actions, I have that one defined in the construtor, that is
> used to open a frame in front of my main Window.
> The case, as I said before, is that when this action is fired, the frame
> stay behind the main window.
>
> This is the Class used for the frame (this is still quite simple):
>
>
> public class Categoria extends Frame implements Bindable {
>
>   private TextInput descricao;
>
>
>   @Override
>   public void initialize(Map<String, Object> arg0, URL arg1, Resources
> arg2) {
>     // TODO Auto-generated method stub
>
>   }
> }
>
>
> and this is the BXML file:
>
>
> <jm:Categoria icon="@application_form.png" title="Categorias"
>     xmlns:bxml="http://pivot.apache.org/bxml"
>     xmlns:content="org.apache.pivot.wtk.content"
>     xmlns="org.apache.pivot.wtk"
>     xmlns:jm="jm.pivot.app.controle" maximized="false"
>     styles="{padding:{top:0, left:4, bottom:4, right:4},
> showWindowControls:true}">
>
>
>     <Border styles="{backgroundColor:null, padding:2}">
>         <BoxPane>
>             <Label text="Descricao:"/>
>             <TextInput bxml:id="descricao"/>
>         </BoxPane>
>     </Border>
>
> </jm:Categoria>
>
>
> Now, I'd like to undestand if I'm doing the right thing, passing the
> Categoria.class in the readObject method, since Categoria class implements
> Bindable.
>
> How can i make Categoria Frame stay in front of Window?
>
>
> Thanks in advance!
>
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Re: BXML doubt

Posted by Greg Brown <gk...@verizon.net>.
I understand your confusion. That particular overload of readObject() is not especially clear. The class argument basically just identifies the name of the resource bundle - it has nothing to do with Bindable.

Your BXML looks fine - to make the frame stay on top of the window, you just need to open the frame with the window as its owner.

On Dec 18, 2010, at 10:39 AM, Luiz Gustavo wrote:

> Hi,
> 
> I'm writing an application, and I'm facing problems to meka a frame stay in front of a Window. I'm following the examples in the tutorial, specifically that one related to Window.
> I still can not understand what is exactly the relation between the bxml file and the base class passed to the BXMLSerializer.readObject method. I'll show what Im doing:
> 
> I have a main class, the entry point to my application:
> 
> public class Main implements Application {
> 
>   private Display display = null;
>   private Window window = null;
>   BXMLSerializer bxmlSerializer;
>   public static final String LANGUAGE_KEY = "language";
> 
> ...
> 
> 
> public Main(){
>     
>    
>     Action.getNamedActions().put("abrirCategorias", new Action() {
>       @Override
>       public void perform(Component source) {
>           try {
>             Categoria categoria = (Categoria) bxmlSerializer.readObject(Categoria.class, "categoria.bxml");
>             categoria.open(display);
>           }
>           catch (IOException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>           }
>           catch (SerializationException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>           }
>       }
>     });    
> 
> 
>     }
>     ...
> 
> 
> }
> 
> Among other Actions, I have that one defined in the construtor, that is used to open a frame in front of my main Window.
> The case, as I said before, is that when this action is fired, the frame stay behind the main window.
> 
> This is the Class used for the frame (this is still quite simple):
> 
> 
> public class Categoria extends Frame implements Bindable {
> 
>   private TextInput descricao;
>   
>   
>   @Override
>   public void initialize(Map<String, Object> arg0, URL arg1, Resources arg2) {
>     // TODO Auto-generated method stub
>     
>   }
> }
> 
> 
> and this is the BXML file:
> 
> 
> <jm:Categoria icon="@application_form.png" title="Categorias"
>     xmlns:bxml="http://pivot.apache.org/bxml"
>     xmlns:content="org.apache.pivot.wtk.content"
>     xmlns="org.apache.pivot.wtk" 
>     xmlns:jm="jm.pivot.app.controle" maximized="false"
>     styles="{padding:{top:0, left:4, bottom:4, right:4}, showWindowControls:true}">
>     
>     
>     <Border styles="{backgroundColor:null, padding:2}">
>         <BoxPane>
>             <Label text="Descricao:"/>
>             <TextInput bxml:id="descricao"/>
>         </BoxPane>
>     </Border>
>     
> </jm:Categoria>
> 
> 
> Now, I'd like to undestand if I'm doing the right thing, passing the Categoria.class in the readObject method, since Categoria class implements Bindable.
> 
> How can i make Categoria Frame stay in front of Window?
> 
> 
> Thanks in advance!