hi, think i made a step forward, but i'm still stuck within.
package gui;
import java.util.ArrayList;
import infrastructure.interfaces.Record;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableModel;
public class test{
ArrayList<Record> results;
public test() {
// // // // // // // // // // // // // // // // // // // // // //
// TEMPORARY RESULTS IMPLEMENTATION //
// // // // // // // // // // // // // // // // // // // // // //
ArrayList<Record> results = new ArrayList<Record>();
results.add(new TempResult("One", "U2", "2007-04-01 08:15:02", "3:42"));
results.add(new TempResult("Two had found three fours of five",
"The Black Eyed Peas", "2007-04-01 08:19:31", "4:07"));
results.add(new TempResult("Number three", "Jonny Cash",
"2007-04-01 08:25:10", "2:58"));
// Das JTable initialisieren
final TableModel rtm = new ReporterTableModel();
final JTable table = new JTable(rtm);
final JFrame frame = new JFrame("Reporter ");
frame.getContentPane().add(new JScrollPane(table));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
new test();
}
// // // // // // // // // // // // // // // // // // // // // //
// TEMPORARY CLASS IMPLEMENTATIONS //
// // // // // // // // // // // // // // // // // // // // // //
/**
* Temporary class that implements Record.
* For testing only.
*
* @author brudt1
*/
class TempResult implements Record
{
private String artist;
private String duration;
private String start;
private String title;
public TempResult(String t, String a, String s, String d)
{
artist = a;
title = t;
start = s;
duration = d;
}
public String getArtist()
{
return artist;
}
public String getEffDuration()
{
return duration;
}
public String getStartTime()
{
return start;
}
public String getTitle()
{
return title;
}
}
The
ReporterTabelModel.java looks like this:
package gui;
import javax.swing.table.AbstractTableModel;
import infrastructure.interfaces.Record;
public class ReporterTableModel extends AbstractTableModel{
public int getColumnCount() {
return 4;
}
public int getRowCount() {
return 0;
}
public Object getValueAt(int rowIndex, int columnIndex) {
Record result = results.get( rowIndex );
return null;
}
@Override
public String getColumnName(int column) {
switch( column ){
case 0: return "Artist";
case 1: return "Title";
case 2: return "Starttime";
case 3: return "Duration";
default: return null;
}
}
}
Now the problem i got - the getValueAt.
There i need access to my ArrayList results and with the columnIndex i have to read the value.
But i couldn't access my results served from test.java.
Thanks
Felissa