Java: how to convert list array values to Object[][] to create table object?

Posted on 2012-08-22
Last Modified: 2012-08-22
Hello Experts,

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){

	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);

        frame.setSize(550, 200);



Open in new window

Below is table constructor:
JTable(Object[ ] [ ] data, Object[ ] header)

Thanks for your help...
Question by:epifanio67
    LVL 86

    Accepted Solution

    String[] headers = { "myColTitle" };

    Open in new window

    You're about to repeat your previous error that i already corrected!, java.util.Vector)

    is what you want

    Author Closing Comment

    ok.... thx for your help...

    LVL 86

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    This video teaches viewers about errors in exception handling.
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now