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");
      }
    }