串口的经典实例
源代码在线查看: frame2.java~24~
package want;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JPanel;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import com.borland.dbswing.TableScrollPane;
import com.borland.dbswing.JdbTable;
import com.borland.dx.sql.dataset.QueryDataSet;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.*;
/**
* Title:
*
* Description:
*
* Copyright: Copyright (c) 2007
*
* Company:
*
* @author not attributable
* @version 1.0
*/
public class Frame2 extends JFrame {
JPanel jPanel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
TableScrollPane tableScrollPane1 = new TableScrollPane();
JdbTable jdbTable1 = new JdbTable();
BorderLayout borderLayout1 = new BorderLayout();
public Frame2(QueryDataSet queryDataSet1) {
try {
jdbTable1.setDataSet(queryDataSet1);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
setSize(new Dimension(400, 300));
jPanel1.add(tableScrollPane1, new XYConstraints(7, 46, 314, 220));
tableScrollPane1.getViewport().add(jdbTable1);
this.getContentPane().add(jPanel1, java.awt.BorderLayout.WEST);
jPanel1.setLayout(xYLayout1);
}
public void jButton1_actionPerformed(ActionEvent e) {
PrinterJob printerJob = PrinterJob.getPrinterJob();
Book book = new Book();
book.append(new PrintText(), new PageFormat());
printerJob.setPageable(book);
boolean doPrint = printerJob.printDialog();
if (doPrint) {
try {
printerJob.print();
} catch (PrinterException exception) {
System.err.println("Printing error: " + exception);
}
}
}
}