Advertisement

[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/09/2006 at 11:04PM PDT, ID: 21844669
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

refresh Jtable

Asked by zolf in Java Programming Language

Tags: jtable, refresh


Hello there,

I have a JTable with database records in it.when i add a new record i want to reload the table dynamically to show the new record,instead of closing and opening the frame again to show the new record.

these are the class and methods that is responsible for the jtable
this is the constr of the class where the table is

public TreeTableInternalFrame(final PictMenuFrameDemo frame)
    {
        super("InternalFrame",
              true, //resizable
              true, //closable
              true, //maximizable
              true);//iconifiable

        Dimension deskSize = frame.getDesktop().getSize();
        setSize((int)deskSize.getWidth() - 20, (int)deskSize.getHeight() - 20);
        //Set the window's location.
        setLocation(10, 10);
        JFParentFrame = frame;
        //get database result in to collections
        initCollections(frame.getDBConnection());
       
        testIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage("images/dslamIcon.png"));
       
         cityIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage("images/cityIcon.png"));
         coIcon =  new ImageIcon(Toolkit.getDefaultToolkit().createImage("images/coIcon.png"));
         dslamIcon =  new ImageIcon(Toolkit.getDefaultToolkit().createImage("images/dslamIcon.png"));
         linecardIcon =  new ImageIcon(Toolkit.getDefaultToolkit().createImage("images/cardIcon.png"));

       
        //set layout for frame content panel
        Container cp = getContentPane();
        cp.setLayout(new BorderLayout());
       
        //create toolbar
        JToolBar toolbar = createToolbar();
        cp.add(toolbar, BorderLayout.NORTH);

        // create popup menu for tree
        //treePopupMenu = createPopupMenuDslam();
       
        // create tree element
        createAndInitTree();
             
        JScrollPane jsp = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
       
       
        //create tab panel
        tabPane = new JTabbedPane();
       
        cityPane = new JPanel(new BorderLayout());
       
        createCityTable();

        jspCity = new JScrollPane(cityTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        cityPane.add(jspCity, BorderLayout.CENTER);
        tabPane.addTab("  City  ", cityIcon, cityPane);
       
        JPanel coPane = new JPanel(new BorderLayout());
        createCoTable();
        JScrollPane jspCo = new JScrollPane(coTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        coPane.add(jspCo, BorderLayout.CENTER);
        tabPane.addTab("   Co   ", coIcon, coPane);
       
        JPanel dslamPane = new JPanel(new BorderLayout());
        createDslamTable();
        JScrollPane jspDslam = new JScrollPane(dslamTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        dslamPane.add(jspDslam, BorderLayout.CENTER);
        tabPane.addTab("  Dslam  ", dslamIcon, dslamPane);
       
       
        JPanel linecardPane = new JPanel(new BorderLayout());
        createlinecardTable();
        JScrollPane jspLinecard = new JScrollPane(linecardTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        linecardPane.add(jspLinecard, BorderLayout.CENTER);
        tabPane.addTab("  Linecard  ", linecardIcon, linecardPane);
               
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, tabPane);
        cp.add(splitPane, BorderLayout.CENTER);
       
        addInternalFrameListener(new InternalFrameAdapter() {
             public void internalFrameClosing(InternalFrameEvent ife) {
                  frame.setInnerFrameNull();  
             }
        });
    }

and this is the method in the above class which is called in another class when i enter new data to be saved in db

public void reloadRecord()
    {
         initCollections(JFParentFrame.getDBConnection());
         //javax.swing.JOptionPane.showMessageDialog(null, "Called");
         createCityTable();
         cityPane.revalidate();
         cityPane.repaint();
    }


and this is the method which is called the first time in the constr of the above class and the second time it is called in the reloadRecord method

private void createCityTable()
    {
         System.out.println("Inside createCityTable() ");
         if (cityTable==null)
         {
            String[] columnNames = {"City ID",
                       "City Farsi Name",
                       "City English Name",
                       "Prefix"};
            model = new DefaultTableModel(columnNames, 0);
           
            for (int i = 0; i < cityCollect.size(); i++)
            {
                 DefaultMutableTreeNode node = (DefaultMutableTreeNode)cityCollect.get(i);
                 CityRow row = (CityRow)node.getUserObject();
                 System.out.println("city "+row);
                 model.addRow(new Object[] {row.getCityId(),
                            row.getCityFarsiName(),
                            row.getCityEngName(),
                            row.getPrefix()
                       });
             
            }
           cityTable = new JTable(model);        
           cityTable.getColumnModel().getColumn(0).setMaxWidth(60);
           cityTable.getColumnModel().getColumn(0).setPreferredWidth(60);
           cityTable.getColumnModel().getColumn(3).setMaxWidth(200);
           cityTable.getColumnModel().getColumn(3).setPreferredWidth(200);
           cityTable.setEnabled(false);
         }
         else
         {
            JOptionPane.showMessageDialog(null, "Clearing table");
            cityTable.setModel(new DefaultTableModel());
         }  
         
    }View the Solution FREE for 30 Days
 
Keywords: refresh Jtable
 
Loading Advertisement...
 
[+][-]05/09/06 11:17 PM, ID: 16645776

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/09/06 11:27 PM, ID: 16645822

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/09/06 11:33 PM, ID: 16645843

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/09/06 11:38 PM, ID: 16645869

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/09/06 11:43 PM, ID: 16645883

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/09/06 11:50 PM, ID: 16645922

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/09/06 11:53 PM, ID: 16645935

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 12:04 AM, ID: 16645979

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 12:46 AM, ID: 16646241

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 12:58 AM, ID: 16646335

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 01:04 AM, ID: 16646394

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 02:08 AM, ID: 16646857

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 02:11 AM, ID: 16646875

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 02:20 AM, ID: 16646917

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 02:29 AM, ID: 16646951

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 02:32 AM, ID: 16646966

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 02:34 AM, ID: 16646975

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 02:39 AM, ID: 16647000

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 02:44 AM, ID: 16647024

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 02:47 AM, ID: 16647044

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 03:21 AM, ID: 16647209

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 03:58 AM, ID: 16647391

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 04:40 AM, ID: 16647599

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/10/06 11:26 PM, ID: 16655671

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/10/06 11:52 PM, ID: 16655760

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/11/06 11:21 PM, ID: 16665104

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/12/06 12:04 AM, ID: 16665267

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/12/06 09:26 PM, ID: 16672558

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/12/06 09:31 PM, ID: 16672566

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/12/06 10:51 PM, ID: 16672716

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/12/06 11:09 PM, ID: 16672740

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/12/06 11:22 PM, ID: 16672763

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/12/06 11:28 PM, ID: 16672776

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/12/06 11:52 PM, ID: 16672813

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/13/06 12:07 AM, ID: 16672867

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/06 12:09 AM, ID: 16672880

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/13/06 12:15 AM, ID: 16672926

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/06 12:17 AM, ID: 16672954

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/13/06 12:19 AM, ID: 16672979

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/06 12:42 AM, ID: 16673095

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/06 12:49 AM, ID: 16673114

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: jtable, refresh
Sign Up Now!
Solution Provided By: objects
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05/13/06 01:12 AM, ID: 16673150

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/06 01:13 AM, ID: 16673152

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/06 01:41 AM, ID: 16673201

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090429-EE-VQP-58