글쓴이 :최종철 1998년 7월 25일 22:36:31
In Reply to: [답변]프린트 코드는 제가 잘못 올렸고요........ posted by 조신제 on 1998년 7월 25일 22:18:59:
프린트를 애플릿을 할려고 하거든요.
조신제님께서 올려주신 프린트 소스는
에러없이 잘되는데요.
이것은 어떻게 사용하는것인지..
잘 몰라서요.
저는 자바를 시작한지 1달정도 되어서..
잘 모르니까, 조금만 도와주십시오.
아래 코드를 이용해서 프린트를 할수 있는 방법은 없을까요 ?
------------- 프린트 예제 ----------------
import java.awt.*;
import java.awt.event.* ;
public class PP extends java.applet.Applet implements ActionListener {
Label status = new Label("Print ME !!");
Button prbtn = new Button("PRINT APPLET") ;
public void init() {
setLayout(new FlowLayout(FlowLayout.CENTER,10,10)) ;
add(status) ;
add(prbtn) ;
prbtn.addActionListener(this) ;
} // init
public Insets getInsets() { return new Insets(10,10,10,10); }
public void start() { }
public void stop() { }
public void actionPerformed (ActionEvent e) {
if (e.getSource() instanceof Button) {
PrintJob job = getToolkit().getPrintJob(this, "Print Test",
null) ;
//(Properties)null) ;
if (job != null) {
Graphics pg = job.getGraphics() ;
if (pg != null) {
printAll(pg) ;
pg.dispose() ;
}
job.end() ;
}
} // instanceof Button
} // actionPerformed
} // top