1

I have a frame that contains a "Compute" button, When I click on the button compute there is a treatment that opens a dialog and a frame. But are below the first frame.

I tried to add setAlwaysOnTop(true) but the frame and dialog that opens remain in the foreground, and the user is forced to close them to return to the previous frame.

Here below the Compute action :

public T compute(){
 //Some code
 HistogramView hv = new HistoGramView(owner, graph);
 AdjustDepthMapDialogVarioMap admap = new AdjustDepthMapDialogVarioMap(owner,text); 
 }
public class HistogramView extends OwnerJFrame{
 //Code
 } 
public class OwnerJFrame extends JFrame{
 //Code
 } 
public class AdjustDepthMapDialogVarioMapextends OwnerJDialog{
 //Code
} 
public class OwnerJDialog extends JDialog{
 //Code
} 

Here is the constructor of HistogramView class :

public HistogramView(Component parent, Graph graph) {
 super("Histogram View");
 graphPanel = new GraphPanel (graph);
 setLocationRelativeTo(parent);
 setTitle("Histogram "); 
 setSize(550, 850);
 pack();
 setVisible(true);
}

Here is the constructor of AdjustDepthMapDialogVarioMap class :

 public AdjustDepthMapDialogVarioMap(Component parent, String text){
 try {
 text= text;
 pack();
 setVisible(true);
}

when the dialogue opens, it must actually open in the foreground. On the other hand, we d'ont want to force it to remain in the foreground (the user must be able to hide it by another dialog if he wishes).

There is a solution without this use of setAlwaysOnTop ?

Andrew Thompson
169k42 gold badges224 silver badges441 bronze badges
asked Sep 14, 2019 at 20:28
3
  • did you tried toFront() or toBack()? Commented Sep 14, 2019 at 20:30
  • 2
    For better help sooner, edit to add a minimal reproducible example or Short, Self Contained, Correct Example. Commented Sep 14, 2019 at 23:57
  • Your main JFrame window must have the setAlwaysOnTop property set to true*. Just before opening your next window (JFrame or JDialog) set the setAlwaysOnTop property for the parent form to false, (since it extends:) this.setAlwaysOnTop(false); new HistogramView().setVisible(true);. You may want to consider a design change and open your windows within the parent JFrame in which case you may want to consider using JInternalFrame's. Commented Sep 15, 2019 at 10:54

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.