0

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

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by mKorbel
1

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.

0

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

0

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.

0

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.

0

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

myTable.getModel().setValueAt(row, column, value);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.