对于我的法语动词变位程序,我试图包括一个打印变位的选项(以表格形式)
但是问题是它打印了一个空白框,我已经阅读了一些地方,这是因为该表在 GUI 或类似的东西中不可见。问题是我希望打印表格而不将其添加到 GUI...
表的代码:
JTable getPrint(String Infinitive)
{
String [] aPresent = fetchTense(Tense.PRESENT, getID(Infinitive)).split("\n");
String [] aPerfect = fetchTense(Tense.PERFECT, getID(Infinitive)).split("\n");
String [] aImperfect = fetchTense(Tense.IMPERFECT, getID(Infinitive)).split("\n");
String [] aSimpleFuture = fetchTense(Tense.SIMPLE, getID(Infinitive)).split("\n");
String [] aConditional = fetchTense(Tense.CONDITIONAL, getID(Infinitive)).split("\n");
String [] aColumnNames = {"Pronoun", "Present" , "Perfect" , "Imperfect" , "Simple Future" , "Conditional" };
String [][] aValues = {
{"Je" , aPresent[0], aPerfect[0], aImperfect[0], aSimpleFuture[0], aConditional[0]},
{"Tu" , aPresent[1], aPerfect[1], aImperfect[1], aSimpleFuture[1], aConditional[1]},
{"Il" , aPresent[2], aPerfect[2], aImperfect[2], aSimpleFuture[2], aConditional[2]},
{"Elle" , aPresent[3], aPerfect[3], aImperfect[3], aSimpleFuture[3], aConditional[3]},
{"On" , aPresent[4], aPerfect[4], aImperfect[4], aSimpleFuture[4], aConditional[4]},
{"Nous" , aPresent[5], aPerfect[5], aImperfect[5], aSimpleFuture[5], aConditional[5]},
{"Vous" , aPresent[6], aPerfect[6], aImperfect[6], aSimpleFuture[6], aConditional[6]},
{"Ils" , aPresent[7], aPerfect[7], aImperfect[7], aSimpleFuture[7], aConditional[7]},
{"Elles" , aPresent[8], aPerfect[8], aImperfect[8], aSimpleFuture[8], aConditional[8]}
};
JTable pTable = new JTable(aValues, aColumnNames);
return pTable;
}
我想用以下代码打印它:
try
{
JTable pTable = pGUI.getParser().getPrint("Aller");
JFrame fix = new JFrame();
fix.add(pTable);
fix.setVisible(true);
fix.setVisible(false);
boolean bComplete = pTable.print(JTable.PrintMode.FIT_WIDTH, new MessageFormat(String.format("Conjugation of %s", "Aller")), new MessageFormat("Page {0}"));
if (bComplete)
{
JOptionPane.showMessageDialog(pGUI, "Finished printing", "Printed", JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(pGUI, "Printing Cancelled", "Printing Cancelled", JOptionPane.WARNING_MESSAGE);
}
}
catch (PrinterException e)
{
JOptionPane.showMessageDialog(pGUI, "An error has occured", "Printing Error", JOptionPane.ERROR_MESSAGE);
}
finally
{
pGUI.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
有谁知道这里出了什么问题,我该如何解决?
另外作为旁注,因为这是一个空白框,我无法确定,但是当它打印时,如果一个单词太长而无法放入单元格中,它会被缩短为单词......例如。如何解决这个问题?