Thanks for the reply. I messed around with the themes and seem to have found that
viewtopic.php?f=18&t=4859 theme works just fine. Maybe I wasn’t using the correct theme names in the other XML files, but at least this one works.
Right so as I was writing my reply with my new bugs, I seem to have fixed them.
Your advice works just fine, I got a SimpleDialog window to appear. I think I’m going to try get the PopupWindow to work (update its working – correctly? We shall see). This is because it seems more customisable, and I’ll need to use it again in another state asking the user for a name.
When you say you can’t add the PopupWindow as a child to any widget, you’re saying the only way to view the PopupWindow is through the method popupWindow.openPopup();. Not by rootpane.add(popupWindow);, because at the moment the only way I can see anything to do with the PopupWindow is by adding it to the rootpane. Here’s my code for the PopupWindow:
Code:
@Override
protected RootPane createRootPane() {
rp = super.createRootPane();
createPopupWindow();
return rp;
}
@Override
protected void layoutRootPane() {
if(pW.isOpen() == true){
pW.adjustSize();
pW.centerPopup();
//pW.setPosition(50, 50);
}
}
Code:
public void createPopupWindow(){
loadPanel = new DialogLayout();
btnOK = new Button("Yes");
btnOK.setTheme("button");
btnOK.addCallback(new Runnable() {
public void run() {
try {
sL.loadGame();
} catch (IOException e) {
e.printStackTrace();
}
loadGame = true;
counter = 5000;
}
});
btnNo = new Button("No");
btnNo.setTheme("button");
btnNo.addCallback(new Runnable() {
public void run() {
//Clear everything in the saved file?
counter = 1000;
loadGame = true;
}
});
btnCancel = new Button("Cancel");
btnCancel.setTheme("button");
btnCancel.addCallback(new Runnable() {
public void run() {
pW.closePopup();
pW.setVisible(false);
pW.destroy();
}
});
loadQuestion = new Label();
loadQuestion.setText("Would you like to carry on with your old game?");
DialogLayout.Group popupLabelH = loadPanel.createSequentialGroup(loadQuestion);
DialogLayout.Group popupBoxH = loadPanel.createSequentialGroup()
.addGap()
.addWidget(btnOK)
.addGap(20)
.addWidget(btnNo)
.addGap(20)
.addWidget(btnCancel)
.addGap();
DialogLayout.Group popupLabelV = loadPanel.createParallelGroup(loadQuestion);
DialogLayout.Group popupBoxV = loadPanel.createParallelGroup(btnOK, btnNo, btnCancel);
loadPanel.setHorizontalGroup(loadPanel.createParallelGroup(popupLabelH, popupBoxH));
loadPanel.setVerticalGroup(loadPanel.createSequentialGroup(popupLabelV, popupBoxV));
pW = new PopupWindow(loadPanel);
pW.setTheme("resizableframe"); //panel, resizableframe?
pW.add(loadPanel);
pW.setVisible(true);
pW.openPopup();
rp.add(pW);
}
The issue I have at the moment is that the PopupWindow is already initialised and on display. I can’t seem to create the popup when I click my start button. (At the moment my start button is a slick2d image but I’ll be changing that later to a TWL button with the same image I have now.) I've tried moving snippets of code around to create the PopupWindow but only display it when clicking the StartButton, all similar to this but I get the errors:
Thu Aug 02 15:22:17 BST 2012 ERROR:Game.update() failure - check the game code.
org.newdawn.slick.SlickException: Game.update() failure - check the game code.
I have a feeling it's to do with the situation I described above, with openPopup() and add(popupWindow), cause at the moment if I comment out openPopup(), it's still visible. But without .add() I don't see anything.
Any ideas? Thanks.