Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4137831

Rounded rectangle does not draw correctly to the printer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs
    • sparc
    • solaris_2.6



      Name: diC59631 Date: 05/13/98


      import java.awt.*;
      import java.awt.event.*;

      public class PrintingTest extends Frame implements ActionListener {

          PrintCanvas canvas;

          public PrintingTest() {
      super("Printing Test");
      canvas = new PrintCanvas();
      add("Center", canvas);

          Font font = new Font("sansserif", Font.BOLD, 14);
          this.setFont(font);

      Button b = new Button("Print");

      b.addActionListener(this);
      add("South", makeSouth());

      pack();
          }

      private Panel makeSouth() {
          Panel p = new Panel();
          Button print = new Button( "print" );
          Button bye = new Button( "exit" );
          print.addActionListener(this);
          p.add( print );
          bye.addActionListener(this);
          p.add( bye );
          return p;
      }


          public void actionPerformed(ActionEvent e) {
      String cmd = e.getActionCommand();
      if (cmd.equals("print")) {
      PrintJob pjob = getToolkit().getPrintJob(this, "Printing Test", null);

      if (pjob != null) {
      Graphics pg = pjob.getGraphics();

      if (pg != null) {
      canvas.printAll(pg);
      pg.dispose();
      }
      pjob.end();

      }
      }
              else System.exit(0);
          }

          public static void main(String args[]) {
      PrintingTest test = new PrintingTest();
      test.show();
          }
      }

      class PrintCanvas extends Canvas {

          public Dimension getPreferredSize() {
              return new Dimension(400, 400);
          }


          public void paint(Graphics g) {
      Rectangle r = getBounds();

          Color fill = new Color(100, 200, 145);
          Color outline = Color.blue;

          // Draw a rounded rectangle
          g.setColor(fill);
          g.fillRoundRect(225, 110, 150, 80, 20, 20);
          g.setColor(outline);
          g.drawRoundRect(225, 110, 150, 80, 20, 20);

          g.setColor(Color.blue);
          g.drawLine(0, 0, r.width, r.height);

          g.setColor(Color.red);
          g.drawLine(0, r.height, r.width, 0);
          }
      }
      (Review ID: 29310)
      ======================================================================

            dmendenhsunw David Mendenhall (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: