JTableを作成してヘッダーとフッターのあるページではなく四角形で表示する次のメソッドがあります。JTableは印刷時にボックスとして表示されます
public void printModules(){
MessageFormat header = new MessageFormat("Modules " + new Date());
MessageFormat footer = new MessageFormat("Created by Assignments Database");
try {
JTable jtModules = new JTable(new ModulesTableModel(Controller.getInstance().getModules()));
jtModules.setShowHorizontalLines(true);
jtModules.setShowVerticalLines(true);
jtModules.setShowGrid(true);
boolean complete = jtModules.print(JTable.PrintMode.NORMAL, header, footer, true, null, false, null);
if(complete){
System.out.println("Printed");
} else{
System.out.println("Printing Cancelled");
}
} catch (PrinterException e) {
e.printStackTrace();
}
}
ほかに何が間違っていますか?同じデータから作成されたデータがパネルの1つに表示されるので、テーブルにデータがあります。私は次のメソッドを実装している私の抽象テーブルモデルで
:
- コンストラクタ
- はgetRowCount
- たgetColumnCount
- がgetValueAt
- getColumnNames
は、他の方法がありますそれはクレアである必要がありますテッド?
楽しい[テーブルの画像を取得する]も参照してください(http://stackoverflow.com/q/7369814/418556)。 ;) –