Perhaps someone could help with problem, I have a feeling there is something wrong with StandardApplet. I'll show you what I mean. Here's some code that works with JME and GBUI projects added Versus.java:
import java.util.concurrent.Callable;
import com.jme.input.InputHandler;
import com.jme.input.MouseInput;
import com.jme.system.DisplaySystem;
import com.jme.util.GameTaskQueueManager;
import com.jme.util.Timer;
import com.jmex.awt.applet.StandardApplet;
import com.jmex.bui.BButton;
import com.jmex.bui.BWindow;
import com.jmex.bui.BuiSystem;
import com.jmex.bui.PolledRootNode;
import com.jmex.bui.event.ActionEvent;
import com.jmex.bui.event.ActionListener;
import com.jmex.bui.layout.AbsoluteLayout;
import com.jmex.bui.util.Point;
import com.jmex.game.StandardGame;
import com.jmex.game.state.BasicGameState;
import com.jmex.game.state.DebugGameState;
import com.jmex.game.state.GameState;
import com.jmex.game.state.GameStateManager;
public class Versus {//extends StandardApplet {
private static final long serialVersionUID = 1L;
public static void main (String[] args) {
StandardGame game = new StandardGame("Woot!");
game.start();
// See the cursor?
MouseInput.get().setCursorVisible(true);
GameState state = new GbuiGameState();
state.setActive(true);
GameStateManager.getInstance().attachChild(state);
DebugGameState base = new DebugGameState();
base.setActive(true);
GameStateManager.getInstance().attachChild(base);
}
/*public void start() {
setSize(640, 480);
super.start();
// See the cursor?
MouseInput.get().setCursorVisible(true);
GameState state = new GbuiGameState();
state.setActive(true);
GameStateManager.getInstance().attachChild(state);
}*/
}
class GbuiGameState extends BasicGameState {
private InputHandler input = new InputHandler();
public GbuiGameState() {
super("Menu");
BuiSystem.init(new PolledRootNode(Timer.getTimer(), input), "/test.bss");
rootNode.attachChild(BuiSystem.getRootNode());
final BWindow bWindow = new BWindow(BuiSystem.getStyle(), new AbsoluteLayout());
final BButton bButton = new BButton("Click Me!");
bButton.setPreferredSize(640, 480);
bButton.addListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
System.out.println("Button Pressed!");
}
});
try {
GameTaskQueueManager.getManager().update(new Callable<Object>() {
public Object call() throws Exception {
bWindow.setSize(640, 480);
bWindow.add(bButton, new Point(0, 0));
BuiSystem.addWindow(bWindow);
bWindow.center();
return null;
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
public void update(float tpf) {
super.update(tpf);
input.update(tpf);
}
}
Make sure to add this bss file test.bss:
root {
color: #FFFFFF;
font: "Dialog" plain 16;
}
root:disabled {
color: #BBBBBB;
}
window {
border: 1 solid #FFFFFF;
}
decoratedwindow {
border: 1 solid #FFFFFF;
}
button:hover {
text-effect: outline;
effect-color: #000000;
}
button {
padding: 3 5;
font: "Dialog" bold 24;
color: #FFFF88;
text-align: center;
}
BuiSystem.init(new PolledRootNode(Timer.getTimer(), input), "/test.bss");
Run it and see that Standard Game works! :D The Button shows up and when you click it, it states it was clicked! :D
Now try uncommenting
extends StandardApplet
public void start() { ..... }
Also comment out the
public static void main(String[] args) { ... }
When you run it now, the Button doesn't show up :(, but when you click the screen the button says it was clicked! :? So apparently the Button is being set up, but not drawn? The code is the same for both, so by logic I deduce that the problem is run with StandardApplet. Is it not loading the bss or is it just not rendering the button? Please help!