epifanio67
asked on
Java: how to convert list array values to Object[][] to create table object?
Hello Experts,
is there a way to convert list array to Object[ ][ ] to construct table object?
Below is table constructor:
JTable(Object[ ] [ ] data, Object[ ] header)
Thanks for your help...
is there a way to convert list array to Object[ ][ ] to construct table object?
public static void main(String args[]) {
Pattern p = Pattern.compile("Sip\\w*");
String file = "message SipRoute test in SipUser " + "\n"
+ "receipt SipCall at time SipUpdate " + "\n"
+ "message SipReg during SipDiv " + "\n";
ArrayList<String> list = new ArrayList<String>();
Object obj[] = null;
Matcher matcher = p.matcher(file);
while(matcher.find() == true){
list.add(matcher.group());
}
Object[]lArray = list.toArray(); //SipRoute, SipUser, SipCall, SipUpdate, SipReg, SipDiv
Object[][] data = new Object[][]{ lArray };
String[] headers = { "myColTitle" };
JFrame frame = new JFrame("test");
JTable table = new JTable(data, headers);
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
frame.getContentPane().add(scrollPane,BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(550, 200);
frame.setVisible(true);
}
Below is table constructor:
JTable(Object[ ] [ ] data, Object[ ] header)
Thanks for your help...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
ASKER
Regards,