public void showTotalSummary()
{
JFrame totalSummary = new JFrame("Total Leave Credit Summary");
totalSummary.setSize(970, 523);
totalSummary.setResizable(false);
totalSummary.setLocationRelativeTo(null);
totalSummary.setVisible(true);
panelTotalSummary = new JPanel();
panelTotalSummary.setBorder ( (Border) new TitledBorder ( new EtchedBorder (), "Display Area" ) );
totalSummary.add(panelTotalSummary);
String[] headings = {"Employee No.", "Employee Names", "Vacation Leave", "Tardiness", "Sick Leave", "Nonattendances", "Total Leave Earned "};
String [][] data = {{"01", "Adlawan","10.50","2.50","20", "4", "30.50"},
{"02","Angeles","20.10","5.90","25","6","45.10"},
{"03","Benenoso","30.70","7.60","34","8","64.70"},
{"04","Bermas","20","4.10","25","3","45"}};
JTable totalSummaryTable = new JTable(data, headings);
totalSummaryTable.getTableHeader().setFont( new Font( "Tahoma" , Font.BOLD, 12 ));
Font f = new Font("Arial", Font.ITALIC, 13);
totalSummaryTable.setFont(f);
totalSummaryTable.setGridColor(Color.BLUE);
totalSummaryTable.setPreferredScrollableViewportSize(new Dimension(900, 400));
totalSummaryTable.setFillsViewportHeight(true);
JScrollPane jcp = new JScrollPane(totalSummaryTable);
jcp.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
panelTotalSummary.add(jcp);
}
使用这些代码,我能够将数据发布到我的 JTable。我的问题是如何从文件中读取数据并从该文件中获取数据并将数据发送到 JTable 中的一行?我知道如何从文件中读取数据并将这些数据发送到 JTextField。我将如何执行相同的过程,但不是将数据发送到 JTextField,而是希望将文件中的数据从 JTabel 发送到一行。任何人的任何持有将不胜感激。