回答内容
回答を評価する
(0ポイント)
|
以下のコードでボタンクリックから印刷ダイアログが表 示されるまでの時間を短縮することが出来ました。
private PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); private BoxScorePanel bsprintPanel = new BoxScorePanel(); private ScoreSheetPanel ssprintPanel = new ScoreSheetPanel();
//印刷ボタン private JButton getJButton0() { if (jButton0 == null) { jButton0 = new JButton(); //ボタンの各印刷文字は各 PreviewPにて指定するので、ここでは空欄のまま jButton0.setText(""); jButton0.setFont(getcellFontSize28()); //ボックススコア final PrinterJob printjob1 = PrinterJob.getPrinterJob(); printjob1.setPrintable(bsprintPanel); //スコアシート final PrinterJob printjob2 = PrinterJob.getPrinterJob(); printjob2.setPrintable(ssprintPanel); //ボタンクリック時のリスナ ー jButton0.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //ボタンク リック効果音を鳴らす btnSound.play(); //もしボッ クススコアボタンがクリックされた場合 if (e.getActionCommand().equals("ボックススコア印 刷")) { try { if (printjob1.printDialog(attributes)) { printjob1.print(attributes); } } catch (PrinterException exception) { JOptionPane.showMessageDialog(SheetDisplayTool.thi s, exception); } //もしスコ アシートボタンがクリックされた場合 } else if (e.getActionCommand().equals("スコアシート印刷")) { try { if (printjob2.printDialog(attributes)) { printjob2.print(attributes); } } catch (PrinterException exception) { JOptionPane.showMessageDialog(SheetDisplayTool.thi s, exception); } } //印刷ダイ アログの「印刷ボタン」&「取り消しボタン」をクリッ クした場合のクリック音 btnSound.play(); } }); } return jButton0; }
|