FengGUI_Alpha12a_Rev634 HelloWorld Problem

Hello,

I posted this problem in a fenggui forum, but people there seems to be busy. I'll try here.



I'm new to FengGUI. I ran the HelloWorld in the newest fengGUI project:

/FengGUI_Alpha12a_Rev634/test/org/fenggui/example/HelloWorld.java



And everything works fine, besides the Window shown does not have any decoration or background.

I think it's not normal that the window looks that way. Ran a similar example from other tutorial, and saw screenshots, where the window looked decorated, with the same code.



I'm not getting any errors/warnings in the console.



I'm using lwjgl 2.0. In order to make FengGUI work with lwjgl 2.0, I imported the project, and changed the path for the import of the class GLU, which is now in lwjgl.util.

I want to use 2.0 because I want to use FengGUI with jme, and it uses 2.0.

I don't know if that could be related with my problem.



I mean the window inside the display, of course.

You're indeed seeing an undecorated FengGUI window.  Are you using an xml theme?  Can you post the code you're using to set it?

/*
 * FengGUI - Java GUIs in OpenGL (http://www.fenggui.org)
 *
 * Copyright (c) 2005-2009 FengGUI Project
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details:
 * http://www.gnu.org/copyleft/lesser.html#TOC3
 *
 * $Id: HelloWorld.java 606 2009-03-13 14:56:05Z marcmenghin $
 */
package org.fenggui.example;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.swing.JFrame;

import org.fenggui.Display;
import org.fenggui.FengGUI;
import org.fenggui.Label;
import org.fenggui.binding.render.jogl.EventBinding;
import org.fenggui.binding.render.jogl.JOGLBinding;
import org.fenggui.composite.Window;
import org.fenggui.util.Alignment;

import com.sun.opengl.util.Animator;

/**
 * The probably simplest runnable FengGUI example in the known
 * part of the galaxy.
 *
 * @author Johannes Schaback

 */
@SuppressWarnings("serial")
public class HelloWorld extends JFrame implements GLEventListener
{

  // the GL class of JOGL
  private GL       gl;

  // the canvas on which the OpenGL will draw his stuff. We keep
  // it as a field because we need the canvas to instantiate the
  // JOGL binding.
  private GLCanvas canvas  = null;

  // The root of the Widget tree.
  private Display  display = null;

  /**
   * Creates the HelloWorld example app.
   *
   */
  public HelloWorld()
  {
    canvas = new GLCanvas();

    canvas.addGLEventListener(this);

    getContentPane().add(canvas, java.awt.BorderLayout.CENTER);
    setSize(500, 300);
    setTitle("FengGUI - Hello FengGUI");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    // we use the Animator to constantly update
    // the screen
    Animator animator = new Animator(canvas);
    animator.start();
  }

  /**
   * Build the GUI.
   */
  public void buildGUI()
  {
    display = FengGUI.createDisplay(new JOGLBinding(canvas));

    new EventBinding(canvas, display);

    Window w = new Window(true, false, false, true);
    Label l = new Label("Hello World!!");
    l.getAppearance().setAlignment(Alignment.MIDDLE);

    w.getContentContainer().addWidget(l);

    w.setXY(50, 50);
    w.setSize(200, 100);

    w.layout();

    display.addWidget(w);
  }

  public void display(GLAutoDrawable arg0)
  {
    gl.glLoadIdentity();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    // pass the control over the OpenGL context to FengGUI so that
    // it can render the GUI.
    display.display();
  }

  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
  {
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();

    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();
  }

  /**
   * JOGL callback method
   */
  public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2)
  {
    // does nothing
  }

  /**
   * JOGL callback method
   */
  public void init(GLAutoDrawable drawable)
  {
    gl = drawable.getGL();
    gl.glClearColor(1.0f, 0.8f, 0.2f, 0.0f);

    // we build the GUI in the render thread! This is important
    // because textures can only be processed in the rendering
    // thread
    buildGUI();
  }

  /**
   * Entrance point to the HelloWorld example.
   */
  public static void main(String[] args)
  {
    new HelloWorld();
  }

}

I made this tutorial:  http://www.fenggui.org/doku.php?id=tut:gettingstarted

and had the same problem. Theres a screenshot with decorated windows :confused:

You need to set up a theme!



// replace XML path with wherever your theme XML is
FengGUI.AddTheme("default", new XMLTheme("data/themes/default/default.xml"));
FengGUI.setTheme("default");

I put this line after generating the display:

FengGUI.setTheme(new XMLTheme("data/themes/QtCurve/QtCurve.xml"));


and it looks the same  :(. I'm not getting any exceptions.

Do you at least get the default theme if you use something like this right after you create the FengGUI display?

DefaultTheme th = new DefaultTheme();
        FengGUI.setTheme(th);


It still looks the same.

 display = FengGUI.createDisplay(new JOGLBinding(canvas));
      DefaultTheme th = new DefaultTheme();
      FengGUI.setTheme(th);

To get theming in newer FengGUI versions you need to use the FengGUI.create* methods. Else widgets will be unthemed. Also you need to set a theme to use before calling the create methods.



So your code should look similar to this:


  /**
   * Build the GUI.
   */
  public void buildGUI()
  {
    display = FengGUI.createDisplay(new JOGLBinding(canvas));

    new EventBinding(canvas, display);

    //set default theme (but I recommend using the XML theme instead)
    FengGUI.setTheme(new DefaultTheme());

    //create your UI
    Window w = FengGUI.createWindow(true, true);
    Label l = FengGUI.createWidget(Label.class);
    l.setText("Hello World!!");
    l.getAppearance().setAlignment(Alignment.MIDDLE);

    w.getContentContainer().addWidget(l);

    w.setXY(50, 50);
    w.setSize(200, 100);

    w.layout();

    display.addWidget(w);
  }