untuk membuat report di jcreator ato di notepad...
gini nih caranya...pertama kita bikin dulu classnya....
langsung aza ya ke kodingnya.... =D

/**
 * @(#)LaporanMahasiswa.java
 *
 *
 * @author "Vina Lishudaifah"
 * @version 1.00 2010/12/14
 */

import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.sql.*;
import java.lang.*;
import javax.swing.*;
import java.util.*;
import java.text.*;

public class LaporanMahasiswa extends JInternalFrame {
private JButton btnCetak1 = new JButton("Print");

    LaporanMahasiswa() {
     /* super(Judul, UkuranFrame, TombolClose, TombolMaksimum, TombolMinimum)*/
super ("Laporan Mahasiswa", false, true, false, true);

/* Mengatur Ukuran Frame */
setSize (350, 150);

btnCetak1.setBounds(100, 28, 85, 35);

/* Memberi addActionListener */
btnCetak1.addActionListener
(
new ActionListener()
{
public void actionPerformed (ActionEvent ae)
{
PrinterJob PrintOK1 = PrinterJob.getPrinterJob();
PrintOK1.setPrintable(new isiRecordMahasiswa());
if (PrintOK1.printDialog())
{
try
{
PrintOK1.print();
   }
catch (PrinterException e)
{
System.out.println(e);
   }
   }
   }
   }
   );

getContentPane().setLayout(null);
getContentPane().add (btnCetak1);

setVisible (true);
}
}

class isiRecordMahasiswa implements Printable
   {
private java.util.Date currDate = new java.util.Date ();
private SimpleDateFormat sdf1 = new SimpleDateFormat ("dd MMMM yyyy", Locale.getDefault());
private String d1 = sdf1.format (currDate) ;

public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
try
{
Graphics2D g1 = (Graphics2D) graphics;
g1.setFont(new Font("Arial", Font.ITALIC, 12));
g1.setColor(Color.black);

/* Koneksi ke Tabel Mahasiswa */
Connect ObjKoneksi1 = new Connect();
  Connection con1 = ObjKoneksi1.OpenConnect();
  Statement st1 = con1.createStatement();
  String sql1 = "SELECT * FROM Mahasiswa";
  ResultSet rs1 = st1.executeQuery(sql1);

int i1, x1, y1;

/* Header (Judul) Laporan */
g1.drawString("Laporan Mahasiswa",100,120);

g1.drawLine(100,145,600,145);

g1.drawString("No.",100,155);
g1.drawString("Nim. ", 130, 155);
g1.drawString("Nama", 190, 155);
g1.drawString("Jk", 280, 155);
g1.drawString("Kel", 350, 155);
g1.drawString("Alamat", 420, 155);

g1.drawLine(100,165,600,165);
x1 = 100;
y1 = 190;
i1 = 1;

/* Print Record Mahasiswa */
while (rs1.next())
{
g1.drawString(""+i1+".",100,y1);
g1.drawString(rs1.getString(1),130,y1);
g1.drawString(rs1.getString(2),190,y1);
g1.drawString(rs1.getString(3),280,y1);
g1.drawString(rs1.getString(4),350,y1);
g1.drawString(rs1.getString(6),420,y1);
               y1 += 14;
i1++;
}
g1.drawLine(x1,y1,600,y1);
g1.drawString("Tanggal Cetak : "+d1,100, y1+14);

rs1.close();
con1.close();
}
catch (Exception e)
{
}
return PAGE_EXISTS;
    }
}

kemudian class yang ini tinggal di panggil deh di void main nya....
How you choose to express yourself
Its all your own and I can tell
It comes naturally,
it comes naturally

You follow what you feel inside,
It's intuitive, you don't have to try,
It comes naturally,
It comes naturally

And it takes my breath away
What you do, so naturally

You are the thunder and I am the lightning,
And I love the way you know who you are,
And to me it's exciting,
When you know it's meant to be,
Everything comes naturally,
It comes naturally,
When you're with me baby,
Everything comes naturally,
It comes naturally,
(Ba-Ba-Baby)

You have a way of moving me,
A force of nature, your energy,
It comes naturally,
(You know it does,)
It comes naturally,
(Oh yeah)

And it takes my breath away (Everytime)
What you do, so naturally

You are the thunder and I am the lightning,
And I love the way you know who you are,
And to me it's exciting,
When you know it's meant to be,
Everything comes naturally,
It comes naturally,
When you're with me baby,
Everything comes naturally,
It comes naturally,
(Ba-Ba-Baby)

When we collide, sparks fly
When you look in my eyes,
it takes my breath away

(You are) You are the thunder and I am the lightening
And I love the way you know who you are
And to me it's exciting
When you know it's meant to be
Everything comes naturally,
it comes naturally
When youre with me, baby
Everything comes naturally,
it comes naturally
Ba-Ba-baby

Naturally (x5)
Ba-Ba-baby

Naturally (x5)
Everything baby comes naturally.
 
blogger template by arcane palette