how can i make the border line to the position shown in the attachment
package proj;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.print.PrinterJob;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
public class j extends javax.swing.JFrame {
public int st,i,k1,k2;PrinterJob printJob = PrinterJob.getPrinterJob();
String str[]=new String[20];
public j() {
initComponents();
}
public class IntroPage implements Printable {
@Override
public int print(Graphics g, PageFormat pageFormat, int page) {
k1=page;
if(k2==k1)
{
k2++;
}
Graphics2D g2d = (Graphics2D) g;
//--- Translate the origin to 0,0 for the top left corner
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
//--- Set the default drawing color to black
g2d.setPaint(Color.black);
//--- Draw a border arround the page
Rectangle2D.Double border = new Rectangle2D.Double(0, 1, 451.224, 696);
g2d.draw(border);
System.out.println("Width:"+pageFormat.getImageableWidth());
System.out.println("Height:"+pageFormat.getImageableHeight());
//--- Print the title
String titleText = "Printing in Java Part "+k2+", Example 4";
g2d.drawString(titleText,200 ,200 );
return (PAGE_EXISTS);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
print = new javax.swing.JButton();
jTextField1.setText("jTextField1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
print.setText("print");
print.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
printActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(86, 86, 86)
.addComponent(print)
.addContainerGap(259, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(57, 57, 57)
.addComponent(print)
.addContainerGap(220, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void printActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Book book = new Book();
PageFormat documentPageFormat = new PageFormat();
documentPageFormat.setOrientation(PageFormat.PORTRAIT);
book.append(new IntroPage(), printJob.defaultPage());
printJob.setPageable(book);
//--- Show the print dialog box. If the user click the
//--- print button we then proceed to print else we cancel
//--- the process.
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception e) { }
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new j().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField jTextField1;
private javax.swing.JButton print;
// End of variables declaration
}