Package java.awt

Examples of java.awt.PrintJob


        file.add(new MenuItem("-"));
        file.add(tmp = new MenuItem("Print"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (pluginLoader.getComponents().get("Terminal") != null) {
              PrintJob printJob =
                      appletFrame.getContentPane().getToolkit()
                      .getPrintJob((JFrame) appletFrame, "JTA Terminal", null);
              ((Component) pluginLoader.getComponents().get("Terminal"))
                      .print(printJob.getGraphics());
              printJob.end();
            }
          }
        });
        file.add(new MenuItem("-"));
        file.add(tmp = new MenuItem("Exit"));
View Full Code Here


      if (setup.getComponents().get("Terminal") != null) {
        file.add(tmp = new JMenuItem("Print"));
        tmp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
              PrintJob printJob =
                      frame.getToolkit().getPrintJob(frame, "JTA Terminal", null);
              // return if the user clicked cancel
              if (printJob == null) return;
              ((JComponent) setup.getComponents().get("Terminal"))
                      .print(printJob.getGraphics());
              printJob.end();
          }
        });
        file.addSeparator();
      }
      file.add(tmp = new JMenuItem("Exit"));
View Full Code Here

    }

    @Override
    public void execute(final Workspace workspace, final View view, final Location at) {
        final Frame frame = new Frame();
        final PrintJob job = Toolkit.getDefaultToolkit().getPrintJob(frame, "Print object", null);

        if (job != null) {
            final Graphics pg = job.getGraphics();
            final Dimension pageSize = job.getPageDimension();

            if (pg != null) {
                pg.translate(LEFT, HEIGHT);
                pg.drawRect(0, 0, pageSize.width - LEFT - 1, pageSize.height - HEIGHT - 1);
                view.print(new PrintCanvas(pg, view));
                pg.dispose();
            }

            job.end();
        }
        frame.dispose();
    }
View Full Code Here

    private static final Font TEXT_FONT = new Font("SansSerif", Font.PLAIN, 10);
    private static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 12);

    public static void print(final String title, final String text) {
        final Frame parent = new Frame();
        final PrintJob job = Toolkit.getDefaultToolkit().getPrintJob(parent, "Print " + title, new Properties());

        if (job != null) {
            final Graphics graphic = job.getGraphics();
            // Dimension pageSize = job.getPageDimension();

            if (graphic != null) {
                graphic.translate(10, 10);
                final int x = 50;
                int y = 50;

                graphic.setFont(TITLE_FONT);

                final int height = graphic.getFontMetrics().getAscent();
                final int width = graphic.getFontMetrics().stringWidth(title);
                graphic.drawRect(x - 10, y - 10 - height, width + 20, height + 20);

                graphic.drawString(title, x, y);

                y += graphic.getFontMetrics().getHeight();
                y += 20;

                graphic.setFont(TEXT_FONT);
                final StringTokenizer tk = new StringTokenizer(text, "\n\r");
                while (tk.hasMoreTokens()) {
                    final String line = tk.nextToken();
                    graphic.drawString(line, x, y);
                    y += graphic.getFontMetrics().getHeight();
                }

                graphic.dispose();
            }

            job.end();
        }
        parent.dispose();
    }
View Full Code Here

    } else if (cmd.equals("close")) {
      frame.setVisible(false);

    } else if (cmd.equals("print")) {  // TBD
      PrintJob pjob = getToolkit().getPrintJob(frame, "Defect Log", null);
      if (pjob != null) {
        Graphics pg = pjob.getGraphics();
        if (pg != null) {
          table.printAll(pg);
          pg.dispose();
        }
        pjob.end();
      }

    } else if (cmd.equals("dts")) {
      if (Settings.isReadOnly()) return;
      if (buildingDtsSelector) return;
View Full Code Here

    private static final Font TEXT_FONT = new Font("SansSerif", Font.PLAIN, 10);
    private static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 12);

    public static void print(final String title, final String text) {
        final Frame parent = new Frame();
        final PrintJob job = Toolkit.getDefaultToolkit().getPrintJob(parent, "Print " + title, new Properties());

        if (job != null) {
            final Graphics graphic = job.getGraphics();
            // Dimension pageSize = job.getPageDimension();

            if (graphic != null) {
                graphic.translate(10, 10);
                final int x = 50;
                int y = 50;

                graphic.setFont(TITLE_FONT);

                final int height = graphic.getFontMetrics().getAscent();
                final int width = graphic.getFontMetrics().stringWidth(title);
                graphic.drawRect(x - 10, y - 10 - height, width + 20, height + 20);

                graphic.drawString(title, x, y);

                y += graphic.getFontMetrics().getHeight();
                y += 20;

                graphic.setFont(TEXT_FONT);
                final StringTokenizer tk = new StringTokenizer(text, "\n\r");
                while (tk.hasMoreTokens()) {
                    final String line = tk.nextToken();
                    graphic.drawString(line, x, y);
                    y += graphic.getFontMetrics().getHeight();
                }

                graphic.dispose();
            }

            job.end();
        }
        parent.dispose();
    }
View Full Code Here

TOP

Related Classes of java.awt.PrintJob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.