• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Modal

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the Swing/AWT forum.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic