/**
  * And a static method to reread this holder. This is used when the selection method is changed
  * via the option menu.
  */
 public void updateSelectionMethod() {
   if (timeForDelayedSelection == null) {
     timeForDelayedSelection = new Tools.IntHolder();
   }
   delayedSelectionEnabled = new Tools.BooleanHolder();
   delayedSelectionEnabled.setValue(
       c.getFrame().getProperty("selection_method").equals("selection_method_direct")
           ? false
           : true);
   /*
    * set time for delay to infinity, if selection_method equals
    * selection_method_by_click.
    */
   if (c.getFrame().getProperty("selection_method").equals("selection_method_by_click")) {
     timeForDelayedSelection.setValue(Integer.MAX_VALUE);
   } else {
     timeForDelayedSelection.setValue(
         Integer.parseInt(c.getFrame().getProperty("time_for_delayed_selection")));
   }
 }
 public void createTimer(MouseEvent e) {
   // stop old timer if present.*/
   stopTimerForDelayedSelection();
   /* Region to check for in the sequel. */
   controlRegionForDelayedSelection = getControlRegion(e.getPoint());
   timerForDelayedSelection = new Timer();
   timerForDelayedSelection.schedule(
       new timeDelayedSelection(c, e),
       /*
        * if the new selection method is not enabled we put 0 to get direct
        * selection.
        */
       (delayedSelectionEnabled.getValue()) ? timeForDelayedSelection.getValue() : 0);
 }
    public void actionPerformed(ActionEvent e) {
      if (!acquirePrinterJobAndPageFormat()) {
        return;
      }

      // Ask about custom printing settings
      final JDialog dialog =
          new JDialog(
              (JFrame) getFrame(), getResourceString("printing_settings"), /* modal= */ true);
      final JCheckBox fitToPage =
          new JCheckBox(
              getResourceString("fit_to_page"),
              Tools.safeEquals("true", getProperty("fit_to_page")));
      final JLabel userZoomL = new JLabel(getResourceString("user_zoom"));
      final JTextField userZoom = new JTextField(getProperty("user_zoom"), 3);
      userZoom.setEditable(!fitToPage.isSelected());
      final JButton okButton = new JButton(getResourceString("ok"));
      final Tools.IntHolder eventSource = new Tools.IntHolder();
      JPanel panel = new JPanel();

      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();

      eventSource.setValue(0);
      okButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              eventSource.setValue(1);
              dialog.dispose();
            }
          });
      fitToPage.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              userZoom.setEditable(e.getStateChange() == ItemEvent.DESELECTED);
            }
          });

      // c.weightx = 0.5;
      c.gridx = 0;
      c.gridy = 0;
      c.gridwidth = 2;
      gridbag.setConstraints(fitToPage, c);
      panel.add(fitToPage);
      c.gridy = 1;
      c.gridwidth = 1;
      gridbag.setConstraints(userZoomL, c);
      panel.add(userZoomL);
      c.gridx = 1;
      c.gridwidth = 1;
      gridbag.setConstraints(userZoom, c);
      panel.add(userZoom);
      c.gridy = 2;
      c.gridx = 0;
      c.gridwidth = 3;
      c.insets = new Insets(10, 0, 0, 0);
      gridbag.setConstraints(okButton, c);
      panel.add(okButton);
      panel.setLayout(gridbag);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      dialog.setContentPane(panel);
      dialog.setLocationRelativeTo((JFrame) getFrame());
      dialog.getRootPane().setDefaultButton(okButton);
      dialog.pack(); // calculate the size
      dialog.show();

      if (eventSource.getValue() == 1) {
        setProperty("user_zoom", userZoom.getText());
        setProperty("fit_to_page", fitToPage.isSelected() ? "true" : "false");
      } else return;

      // Ask user for page format (e.g., portrait/landscape)
      pageFormat = printerJob.pageDialog(pageFormat);
      if (pageFormat.getOrientation() == PageFormat.LANDSCAPE) {
        setProperty("page_orientation", "landscape");
      } else if (pageFormat.getOrientation() == PageFormat.PORTRAIT) {
        setProperty("page_orientation", "portrait");
      } else if (pageFormat.getOrientation() == PageFormat.REVERSE_LANDSCAPE) {
        setProperty("page_orientation", "reverse_landscape");
      }
    }