Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8873959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:36:01+00:00 2026-06-14T18:36:01+00:00

I am using a DAO Factory to get my Data from the database. When

  • 0

I am using a DAO Factory to get my Data from the database. When i am running my program the data is showing in the printline so he is getting it out of the database. But i want it to show in my JTable but this one is empty and i dont know how to fill it.

Code JFrame:

package View;

import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
import javax.swing.table.TableModel;

import Controller.VerwijderController;
import Model.OefeningenListModel;
import Model.OefeningenTableModel;

public class VerwijderenHome extends JFrame {

    private JList LijstOefening;
    private JScrollPane jScrollPane1;
    private Container window = getContentPane();
    private JButton delete;
    private VerwijderController Controller;
    private JTable tabel;

    public VerwijderenHome()
    {
        initGUI();
    }

    public void addDeleteListener(ActionListener a){
        delete.addActionListener(a);
    }

    private void initGUI() {
        setPreferredSize(new Dimension(800, 600));
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setLayout(null);
        setVisible(true);

        JTable table = new JTable(new OefeningenTableModel());              
        JScrollPane scrollPane = new JScrollPane(table);  
        scrollPane.setBounds(50, 50, 300, 60);
        window.add(scrollPane);

        delete = new JButton("Delete");
        delete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        delete.setBounds(50, 265, 100, 30);
        window.add(delete);

        pack();


        Controller = new VerwijderController();
        addDeleteListener(Controller);

    }

    public JButton getDelete(){
        return delete;
    }

    public JList getLijst()
    {
        return LijstOefening;


}
    }

Code DefaultTableModel?? (Dont know if i must use this one)

package Model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;

import datapackage.DAOFactory;

public class OefeningenTableModel extends DefaultTableModel {

      ArrayList<Oefening> oefeningen;

      public OefeningenTableModel(){

          oefeningen = DAOFactory.getFactory(0).getIDAOOefening().load();

      }




    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:36:02+00:00Added an answer on June 14, 2026 at 6:36 pm

    The DefaultTableModel is backed by a Vector representing the columns and rows of the table model.

    You’ve provided your own ArrayList of objects, but you’ve not overridden the methods you will require to supply that data back to the table. The DefaultTableModel has no idea of your ArrayList

    Try overridding some of the following;

    public class OefeningenTableModel extends AbstractTableModel {
    
        ArrayList<Oefening> oefeningen;
    
        public OefeningenTableModel(){
            oefeningen = DAOFactory.getFactory(0).getIDAOOefening().load();
        }    
    
        @Override
        public int getRowCount() {
            return oefeningen.getSize();
        }
    
        @Override
        public int getColumnCount() {
            // You'll need to fill this out to meet your requirements
        }
    
        @Override
        public String getColumnName(ing column) {
            // You'll need to fill this out to meet your requirements
        }
    
        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            // You'll need to fill this out to meet your requirements
        }
    
    }
    

    Take the time to have read through How to use Tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a class separate from my DAO to handle access requests, but
I'm testing my DAO layer using DbUnit. I'm prefilling database from XML dataset, doing
I was using http://www.yiiframework.com/doc/guide/1.1/en/database.dao Data Access Objects (DAO) uses PDO. Was unsure which was
I'm developing Web Service that has access to database via JDBC. I'm using DAO
I'm trying to figure out if I'm using the DAO pattern correctly and, more
I have a DAO class which I am using to do database operations. I
I'm in the processes of changing my DAO layer from using Hibernate API to
I am working with an Access 2003 database that has a subroutine using DAO
Using Hibernate 4 and Spring 3.1. Just getting up and running with it so
I prefer using JPA Entitymanager factory obtain via LocalContainerEntityManagerFactoryBean for persistence. But I hit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.