I'm currently working on a project for my JAVA class. The user picks, from a two dropdown boxes, the times he is busy (military time). And at the bottom of the form, there is a table which displays the times he is busy, and the tables arranges the times from earliest to the latest. Now my question is: How do I do this? Can any one explain? Take note I'm a first time JAVA user, and I'm just practicing to get better. :D

Start with this.

When you have some basics in place, post back with your code and specific questions about the parts that are giving you trouble.

I made a JTable using NetBeans. I just need to know how to display the chosen items from the combobox in the JTable.

And that is the reason I linked the tutorial. You need to add those items to the table model, which can be a DefaultTableModel or one of your own creation.

So, here's my code:

ScheduleTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"", null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "User 1 Schedule", "User 2 Schedule", "Free time", "Duration"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

So, I was thinking that I should replace the:

{"", null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}

to the chosen item from the combo box?
In my combo box, I have about 20 choices. And when the user picks one, it is displayed in the table.

that isn't code, there I missed definitions for JTable, JComboBox, whatever about Swing and your code logics

myTable.getModel().setValueAt(row, column, value);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.