Reputation: 21
I did my first java app to run on a raspberry and I'm having difficult with messagebox. When I press escape key it should appear asking if i really want to exit or not, but instead of appear on top of the main frame, the messagebox appear on the back of the main frame. If i press the messagebox buttons the correct actions occur. this is the code i wrote:
private void Mensagem()
{
Display display = new Display();
Shell shell = new Shell(display);
int botoes = SWT.ICON_QUESTION |SWT.YES | SWT.NO;
MessageBox mensagem = new MessageBox(shell, botoes);
mensagem.setMessage("Deseja sair?");
int botao = mensagem.open();
//System.out.println(mensagem.getParent());
switch (botao)
{
case SWT.YES:
//System.out.println("SWT.YES");
Runtime.getRuntime().exit(0);
break;
case SWT.NO:
//System.out.println("SWT.NO");
break;
}
shell.pack();
display.dispose();
}
Can anyone help me? Thanks in advance, Joaquim
Upvotes: 2
Views: 334
Reputation: 172
Add SWT.APPLICATION_MODAL to the flags when building the shell:
new Shell(Display, SWT.APPLICATION_MODAL);
Failing it, maybe with SWT.PRIMARY_MODAL or SWT.SYSTEM_MODAL
Edit: I was wrong, it actually is SWT.ON_TOP
Upvotes: 1