NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Import data form text into Jtable

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
redpower1989



Joined: 17 Nov 2011
Posts: 2

PostPosted: Thu Nov 24, 2011 8:40 am    Post subject: Import data form text into Jtable Reply with quote

Hello i made a GUI. In that GUI i make a Jtable here the code that i make the Jtable with name table 1
Code:
 centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                    inCenterPanel = new JPanel(new GridLayout(1, 2));
                    label4 = new JLabel("A= ");
                    inCenterPanel.add(label4);
                    table1 = new JTable(x, x);
                    table1.setBackground(Color.red);
                    inCenterPanel.add(table1);
                    centerPanel.setBackground(Color.green);
                    inCenterPanel.setBackground(Color.green);
                    centerPanel.add(inCenterPanel);
                    contentPane.add(centerPanel, BorderLayout.NORTH);


I make o method that i want the GUI read from text file and put the int elements into the jtable with name table 1! here is the code which i try to make that and i dont now how
Code:
public void data2() {


        try {
            // Open the file that is the first
            // command line parameter
            FileInputStream fstream = new FileInputStream("data.txt");
            // Get the object of DataInputStream
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;
            //Read File Line By Line
            while ((strLine = br.readLine()) != null) {
                for (int i = 0; i < x; i++) {
                    for (int j = 0; j < x; j++) {

                       

                    }
                }


            }
            //Close the input stream
            in.close();
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }

    }


Can you help me ? i make this thread also here http://www.coderanch.com/t/559727/GUI/java/Import-data-text-Jtable#2540842
Back to top
jyeary



Joined: 21 Oct 2008
Posts: 635
Location: Simpsonville, SC

PostPosted: Tue Dec 06, 2011 3:33 am    Post subject: Re: Import data form text into Jtable Reply with quote

This is the wrong forum for GUI based questions, please use the
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo