Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Modal  RSS feed

 
Richard Mendoza
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created an instance of a frame. Inside this frame is a button "Print". If I click on this button, I instantiated an object from the PrintJob class. With this object, I invoked the printDialog() method showing a dialog box. Below is the snippet of the code:
void jButton8_actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat landscape = job.defaultPage();
landscape.setOrientation(PageFormat.PORTRAIT);
job.setPrintable(new SOSReport(), job.defaultPage());
if(job.printDialog()) { // loads a dialog box
try { job.print(); }
catch(Exception e1) {insert_log(e1.getMessage());}
}
}
When this dialog box appear, I want it to be modal. The frame at the back of this dialog box should be inactivated. Also, I want to remove the minimize button of this dialog box.
How do I do it?

Thanks,

Richard
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Swing/AWT forum.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use one of the constructors that take a Frame and boolean as input.
JDialog(Frame owner, boolean modal)

The method that you create the dialog in needs to have a reference to the frame that will be the owner. (The one you want disabled) Make the modal flag true and that is it.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!