Hi there,
I am having some troubles with the DialogLayout. After I figured out, how to set the position of all widgets in a DialogLayout, now I have the problem to set the sizes of the widgets.
The problem is the following: I have just three buttons in one DialogLayout, all centered to the middle of the screen (horizontally).
But every button has a different size (depending on its caption).
Here is a screen picture of the program:
http://s14.directupload.net/file/d/3040/n626hh3z_png.htmI already read that you should not call setSize() or something equals somewhere else than in the layout() method.
So, is it possible, to make the buttons have all the same size, but all depending on the size of the screen (for different resolutions).
My code is here:
Code:
private void initMainMenu(){
mainMenu = new DialogLayout();
mainMenu.setClip(true);
mainMenu.setTheme("");
startGameButton.setTheme("button");
startGameButton.setModel(new SimpleButtonModel());
startGameButton.setFont(theme.getDefaultFont());
startGameButton.addCallback(new Runnable() {
@Override
public void run() {
startGameMenu.setVisible(true);
mainMenu.setVisible(false);
}
});
loadSettingButton.setTheme("button");
loadSettingButton.setModel(new SimpleButtonModel());
loadSettingButton.setFont(theme.getDefaultFont());
loadSettingButton.addCallback(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
});
endGameButton.setTheme("button");
endGameButton.setModel(new SimpleButtonModel());
endGameButton.setFont(theme.getDefaultFont());
endGameButton.addCallback(new Runnable() {
@Override
public void run() {
System.exit(0);
}
});
mainMenu.setDefaultGap(new Dimension(0, solution.y/5));
DialogLayout.Group mainMenuGroupHorizontal = mainMenu.createParallelGroup();
DialogLayout.Group mainMenuGroupVertical = mainMenu.createSequentialGroup();
mainMenuGroupHorizontal.addWidget(startGameButton, Alignment.CENTER);
mainMenuGroupHorizontal.addWidget(loadSettingButton, Alignment.CENTER);
mainMenuGroupHorizontal.addWidget(endGameButton, Alignment.CENTER);
mainMenuGroupVertical.addGap(solution.y/5);
mainMenuGroupVertical.addWidget(startGameButton);
mainMenuGroupVertical.addWidget(loadSettingButton);
mainMenuGroupVertical.addWidget(endGameButton);
mainMenu.setHorizontalGroup(mainMenuGroupHorizontal);
mainMenu.setVerticalGroup(mainMenuGroupVertical);
}
Greetings,
M0rgenstern