Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Serphentelm
Contributor III
Contributor III

MessageBox from a Jpane appears under all the windows

Hi,

I've a Job with 2 Tjava at the end. In those Tjava I've written some custom code that will check some data in given tables and if I encounter an anomlay, I've set up to display a message box using Jpane. The problem rises when the msgbox is not showed in the first layer, but is instead overlayed by all the windows.

Since I've got a plenty of this cheks, I've used some routines to semplify the process of using lot of tmsgBox.

Is there a way to let the message appear in front of all the windows?

Thanks

Labels (2)
1 Solution

Accepted Solutions
anselmopeixoto
Partner - Creator III
Partner - Creator III

Hello @matteo marchesi​ 

 

I can't tell why the JPanel is being overlayed by all other windows without looking at your code, but what I usually do is use a JPanel inside a JFrame and it works pretty well. Here's an example:

 

JFrame frame = new JFrame("Window");

       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       //frame.setLayout(new GridLayout(7, 2, 10, 10)); // 7 rows, 2 columns, with gaps

 

       // Create a JPanel with a BorderLayout

       JPanel panel = new JPanel(new BorderLayout());

       panel.setLayout(new GridLayout(7, 2, 10, 10));

       frame.add(panel);

 

//panel content goes here

 

frame.pack();

       frame.setLocationRelativeTo(null); // center the window

       frame.setVisible(true);

       frame.setSize(400, 300); //set window size

       frame.setResizable(false);

 

I hope it helps.

 

Best regards,

Anselmo

View solution in original post

2 Replies
anselmopeixoto
Partner - Creator III
Partner - Creator III

Hello @matteo marchesi​ 

 

I can't tell why the JPanel is being overlayed by all other windows without looking at your code, but what I usually do is use a JPanel inside a JFrame and it works pretty well. Here's an example:

 

JFrame frame = new JFrame("Window");

       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       //frame.setLayout(new GridLayout(7, 2, 10, 10)); // 7 rows, 2 columns, with gaps

 

       // Create a JPanel with a BorderLayout

       JPanel panel = new JPanel(new BorderLayout());

       panel.setLayout(new GridLayout(7, 2, 10, 10));

       frame.add(panel);

 

//panel content goes here

 

frame.pack();

       frame.setLocationRelativeTo(null); // center the window

       frame.setVisible(true);

       frame.setSize(400, 300); //set window size

       frame.setResizable(false);

 

I hope it helps.

 

Best regards,

Anselmo

Serphentelm
Contributor III
Contributor III
Author

Thank you @Anselmo Peixoto​, I've missed the  "frame.setVisible(true);" line.

Using that, now my panel is showed with priority over the other windows.

 

Thanks