Hi Guys,

I ussually dont post anything here often, just get everything off of everyone elses questions,
but I'm having a strange problem that im scratching my head over,

I have a JTable where I can Add and remove rows... This is just for testing purposes, I'm about to make a ingrediants program.
The thing is whenever I change one of the Comboboxes they all seem to change.. its really wierd,

Could Someone run this and help me out, this is probably a stupid mistake?

See my Code Below,

My Main

package doughtracker;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @Author Jonathan 
 */
public class DoughTracker {

    static Dimensions dimensions;

    public static void main(String[] args) {
        dimensions = new Dimensions();
        try {
            // Set System L&F
            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            System.out.println(e);
        }

        Window window = new Window();
        window.window();

    }

}

Dimensions class,

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package doughtracker;

/**
 *
 * @author Jonathan Schep
 */
public class Dimensions {

    int windowWidth;
    int windowHieght;

    int ingrediantPanelX;
    int ingrediantPanelY;
    int ingrediantPanelWidth;
    int ingrediantPanelHieght;

    int notesPanelX;
    int notesPanelY;
    int notesPanelWidth;
    int notesPanelHieght;

    int doughCreatorX;
    int doughCreatorY;
    int doughCreatorWidth;
    int doughCreatorHieght;

    public Dimensions() {

        windowWidth = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
        windowHieght = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;

        ingrediantPanelX = 50;
        ingrediantPanelY = 50;
        ingrediantPanelWidth = windowWidth / 3;
        ingrediantPanelHieght = windowHieght - 125;

        notesPanelWidth = windowWidth / 4;
        notesPanelHieght = windowHieght / 3;
        notesPanelX = windowWidth - notesPanelWidth - 50;
        notesPanelY = windowHieght - notesPanelHieght - 75;

        doughCreatorX = 50;
        doughCreatorY= 50;
        doughCreatorWidth = windowWidth - 100;
        doughCreatorHieght = windowHieght-125;
    }

        public int getdoughCreatorX() {
        return doughCreatorX;
    }

    public int getdoughCreatorY() {
        return doughCreatorY;
    }

    public int getdoughCreatorWidth() {
        return doughCreatorWidth;
    }

    public int getdoughCreatorHieght() {
        return doughCreatorHieght;
    }

    public int getNotesPanelX() {
        return notesPanelX;
    }

    public int getNotesPanelY() {
        return notesPanelY;
    }

    public int getNotesPanelWidth() {
        return notesPanelWidth;
    }

    public int getNotesPanelHieght() {
        return notesPanelHieght;
    }

    public int getIngrediantPanelX() {
        return ingrediantPanelX;
    }

    public int getIngrediantPanelY() {
        return ingrediantPanelY;
    }

    public int getIngrediantPanelWidth() {
        return ingrediantPanelWidth;
    }

    public int getIngrediantPanelHieght() {
        return ingrediantPanelHieght;
    }

    public int getWindowWidth() {
        return windowWidth;
    }

    public int getWindowHieght() {
        return windowHieght;
    }
}

my Dough Creator pane

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package doughtracker;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

/**
 *
 * @author Jonathan Schep
 */
public class DoughCreator extends JPanel {

    public DoughCreator() {
        Border GrayLine = BorderFactory.createLineBorder(Color.LIGHT_GRAY);

        super.setBounds(DoughTracker.dimensions.doughCreatorX, DoughTracker.dimensions.doughCreatorY, DoughTracker.dimensions.doughCreatorWidth, DoughTracker.dimensions.doughCreatorHieght);
        super.setLayout(null);
        super.setBorder(GrayLine);

        JLabel NameLabel = new JLabel("Dough Name:");
        NameLabel.setFont(new Font("Ariel", Font.BOLD + Font.ITALIC, 32));
        NameLabel.setBounds(25, 25, 250, 50);
        super.add(NameLabel);

        JLabel doughName = new JLabel("Gluten Free testing label");
        doughName.setFont(new Font("Ariel", Font.PLAIN + Font.ITALIC, 32));
        doughName.setBounds(260, 25, DoughTracker.dimensions.doughCreatorWidth - 300, 50);
        super.add(doughName);

        JTextField doughTypeTextField = new JTextField("");
        doughTypeTextField.setFont(new Font("Ariel", Font.PLAIN, 32));
        doughTypeTextField.setOpaque(false);
        doughTypeTextField.setToolTipText("The name of the Dough...");
        doughTypeTextField.setBounds(260, 25, DoughTracker.dimensions.doughCreatorWidth - 300, 50);
        doughTypeTextField.setBorder(GrayLine);
        doughTypeTextField.setEditable(true);
        doughTypeTextField.setVisible(false);
        super.add(doughTypeTextField);

        JTable ingrediantsTable = new JTable() {
            @Override
            public boolean isCellEditable(int row, int column) {

                return true;
            }
        };
        ingrediantsTable.setGridColor(Color.LIGHT_GRAY);
        ingrediantsTable.getTableHeader().setFont(new Font("Arial", Font.BOLD, 16));
        ingrediantsTable.setFont(new Font("Ariel", Font.PLAIN, 16));
        // MainWindowTable.setDefaultRenderer(Object.class, new MyCellRenderer());
        ingrediantsTable.setRowHeight(25);
        ingrediantsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        ingrediantsTable.getTableHeader().setPreferredSize(new Dimension(300, 40));
        ingrediantsTable.setFocusable(false);

        DefaultTableModel ingrediantsTableModel = new DefaultTableModel();
        ingrediantsTableModel.addColumn("Ingrediant");
        ingrediantsTableModel.addColumn("Amount");
        ingrediantsTableModel.addColumn("Unit");

        ingrediantsTable.setModel(ingrediantsTableModel);

         String[] values = new String[] { "1", "2", "3" };

        TableColumn col = ingrediantsTable.getColumnModel().getColumn(0);
    col.setCellEditor(new MyComboBoxEditor(values));
    col.setCellRenderer(new MyComboBoxRenderer(values));

        JScrollPane ingrediantsTableScrollPane = new JScrollPane(ingrediantsTable);
        ingrediantsTableScrollPane.setBounds(25, 100, DoughTracker.dimensions.doughCreatorWidth / 3, DoughTracker.dimensions.doughCreatorHieght - 100);
        ingrediantsTableScrollPane.setVisible(true);
        ingrediantsTableScrollPane.setBackground(Color.WHITE);
        super.add(ingrediantsTableScrollPane);

        JButton addIngrediantButton = new JButton("+");
        addIngrediantButton.setFont(new Font("Arial", Font.BOLD, 18));
        addIngrediantButton.setToolTipText("Add an Ingrediant");
        addIngrediantButton.setOpaque(false);
        addIngrediantButton.setContentAreaFilled(true);
        addIngrediantButton.setBorderPainted(false);
        addIngrediantButton.setFocusable(false);
        addIngrediantButton.setBounds(DoughTracker.dimensions.doughCreatorWidth / 3 + 50, 100, 50, 50);
        addIngrediantButton.setVisible(true);
        addIngrediantButton.setEnabled(true);
        addIngrediantButton.addActionListener((ActionEvent e) -> {
            ingrediantsTableModel.addRow(new Object[]{"", ""});
        });

        super.add(addIngrediantButton);

        JButton removeIngrediantButton = new JButton("-");
        removeIngrediantButton.setFont(new Font("Arial", Font.BOLD, 18));
        removeIngrediantButton.setToolTipText("Add an Ingrediant");
        removeIngrediantButton.setOpaque(false);
        removeIngrediantButton.setContentAreaFilled(true);
        removeIngrediantButton.setBorderPainted(false);
        removeIngrediantButton.setFocusable(false);
        removeIngrediantButton.setBounds(DoughTracker.dimensions.doughCreatorWidth / 3 + 50, 160, 50, 50);
        removeIngrediantButton.setVisible(true);
        removeIngrediantButton.setEnabled(true);
        removeIngrediantButton.addActionListener((ActionEvent e) -> {
            if (ingrediantsTable.getSelectedRow() != -1) {
                ingrediantsTableModel.removeRow(ingrediantsTable.getSelectedRow());
            } else {
                Toolkit.getDefaultToolkit().beep();
            }
        });
        super.add(removeIngrediantButton);

    }

    class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {

        public MyComboBoxRenderer(String[] items) {
            super(items);
        }

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                super.setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            }

            return this;
        }
    }

    class MyComboBoxEditor extends DefaultCellEditor {

        public MyComboBoxEditor(String[] items) {
            super(new JComboBox(items));
        }
    }

}

At a quick look it seems that all the cells in Col 0 share exactly the same renderer and editor , so they should all look exactly the same all the time!

commented: That's how clones are made! +15

I am able to add and remove cells through, how would that work?

I noticed I deleted this when I posted the code,

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package doughtracker;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

/**
 *
 * @author Jonathan Schep
 */
public class DoughCreator extends JPanel {

    public DoughCreator() {
        Border GrayLine = BorderFactory.createLineBorder(Color.LIGHT_GRAY);

        super.setBounds(DoughTracker.dimensions.doughCreatorX, DoughTracker.dimensions.doughCreatorY, DoughTracker.dimensions.doughCreatorWidth, DoughTracker.dimensions.doughCreatorHieght);
        super.setLayout(null);
        super.setBorder(GrayLine);

        JLabel NameLabel = new JLabel("Dough Name:");
        NameLabel.setFont(new Font("Ariel", Font.BOLD + Font.ITALIC, 32));
        NameLabel.setBounds(25, 25, 250, 50);
        super.add(NameLabel);

        JLabel doughName = new JLabel("Gluten Free testing label");
        doughName.setFont(new Font("Ariel", Font.PLAIN + Font.ITALIC, 32));
        doughName.setBounds(260, 25, DoughTracker.dimensions.doughCreatorWidth - 300, 50);
        super.add(doughName);

        JTextField doughTypeTextField = new JTextField("");
        doughTypeTextField.setFont(new Font("Ariel", Font.PLAIN, 32));
        doughTypeTextField.setOpaque(false);
        doughTypeTextField.setToolTipText("The name of the Dough...");
        doughTypeTextField.setBounds(260, 25, DoughTracker.dimensions.doughCreatorWidth - 300, 50);
        doughTypeTextField.setBorder(GrayLine);
        doughTypeTextField.setEditable(true);
        doughTypeTextField.setVisible(false);
        super.add(doughTypeTextField);

        JTable ingrediantsTable = new JTable() {
            @Override
            public boolean isCellEditable(int row, int column) {

                return true;
            }
        };
        ingrediantsTable.setGridColor(Color.LIGHT_GRAY);
        ingrediantsTable.getTableHeader().setFont(new Font("Arial", Font.BOLD, 16));
        ingrediantsTable.setFont(new Font("Ariel", Font.PLAIN, 16));
        // MainWindowTable.setDefaultRenderer(Object.class, new MyCellRenderer());
        ingrediantsTable.setRowHeight(25);
        ingrediantsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        ingrediantsTable.getTableHeader().setPreferredSize(new Dimension(300, 40));
        ingrediantsTable.setFocusable(false);

        DefaultTableModel ingrediantsTableModel = new DefaultTableModel();
        ingrediantsTableModel.addColumn("Ingrediant");
        ingrediantsTableModel.addColumn("Amount");
        ingrediantsTableModel.addColumn("Unit");

        ingrediantsTable.setModel(ingrediantsTableModel);

         String[] values = new String[] { "1", "2", "3" };

        TableColumn col = ingrediantsTable.getColumnModel().getColumn(0);
    col.setCellEditor(new MyComboBoxEditor(values));
    col.setCellRenderer(new MyComboBoxRenderer(values));

        JScrollPane ingrediantsTableScrollPane = new JScrollPane(ingrediantsTable);
        ingrediantsTableScrollPane.setBounds(25, 100, DoughTracker.dimensions.doughCreatorWidth / 3, DoughTracker.dimensions.doughCreatorHieght - 100);
        ingrediantsTableScrollPane.setVisible(true);
        ingrediantsTableScrollPane.setBackground(Color.WHITE);
        super.add(ingrediantsTableScrollPane);

        JButton addIngrediantButton = new JButton("+");
        addIngrediantButton.setFont(new Font("Arial", Font.BOLD, 18));
        addIngrediantButton.setToolTipText("Add an Ingrediant");
        addIngrediantButton.setOpaque(false);
        addIngrediantButton.setContentAreaFilled(true);
        addIngrediantButton.setBorderPainted(false);
        addIngrediantButton.setFocusable(false);
        addIngrediantButton.setBounds(DoughTracker.dimensions.doughCreatorWidth / 3 + 50, 100, 50, 50);
        addIngrediantButton.setVisible(true);
        addIngrediantButton.setEnabled(true);
        addIngrediantButton.addActionListener((ActionEvent e) -> {
            ingrediantsTableModel.addRow(new Object[]{"", ""});
        });

        super.add(addIngrediantButton);

        JButton removeIngrediantButton = new JButton("-");
        removeIngrediantButton.setFont(new Font("Arial", Font.BOLD, 18));
        removeIngrediantButton.setToolTipText("Add an Ingrediant");
        removeIngrediantButton.setOpaque(false);
        removeIngrediantButton.setContentAreaFilled(true);
        removeIngrediantButton.setBorderPainted(false);
        removeIngrediantButton.setFocusable(false);
        removeIngrediantButton.setBounds(DoughTracker.dimensions.doughCreatorWidth / 3 + 50, 160, 50, 50);
        removeIngrediantButton.setVisible(true);
        removeIngrediantButton.setEnabled(true);
        removeIngrediantButton.addActionListener((ActionEvent e) -> {
            if (ingrediantsTable.getSelectedRow() != -1) {
                ingrediantsTableModel.removeRow(ingrediantsTable.getSelectedRow());
            } else {
                Toolkit.getDefaultToolkit().beep();
            }
        });
        super.add(removeIngrediantButton);

    }

    class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {

        public MyComboBoxRenderer(String[] items) {
            super(items);
        }

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                super.setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            }
                setSelectedItem(value);
            return this;
        }
    }

    class MyComboBoxEditor extends DefaultCellEditor {

        public MyComboBoxEditor(String[] items) {
            super(new JComboBox(items));
        }
    }

}

setSelectedItem(value);

This goes in table cell renderrer component.

Are you saying that the missing line was the fix for the problem (looks like it should be!), or do youy still have the problem with that line in place?

No I'm still having the exact same problem... the line was accidently removed when pasting to the forum.

I think you need to run it to understand what I mean. Like I said I'm more than likely making a stupid mistake but I don't know anymore

Sorry, I don't have the time to set up a multi-file project to try that...
Can you strip it down to a single small file that demonstrates the problem?

Quikly threw this together, run it click on the + button to add a few rows in the table and select somthing from 1 of the comboboxes,

They all change?

package doughtracker;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

/**
 *
 * @Author Jonathan
 */
public class DoughTracker {

    static Dimensions dimensions;

    public static void main(String[] args) {
        dimensions = new Dimensions();
        try {
            // Set System L&F
            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            System.out.println(e);
        }

        JFrame MainFrame = new JFrame("Dough Tracker V 0.1 Beta");
        JPanel BorderPanel = new JPanel();
        BorderPanel.setBorder(new LineBorder(Color.GRAY));
        BorderPanel.setLayout(new FlowLayout());
        BorderPanel.setOpaque(false);
        MainFrame.getContentPane().add(BorderPanel);
        MainFrame.setSize(DoughTracker.dimensions.getWindowWidth(), DoughTracker.dimensions.getWindowHieght());
        MainFrame.setResizable(false);
        MainFrame.setLocationRelativeTo(null);
        MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MainFrame.setAlwaysOnTop(false);
        MainFrame.getContentPane().setLayout(null);
        // InventoryMainFrame.setIconImage(new ImageIcon("Resources/Images/CrumbTrackerIcon.png").getImage());
        //MainFrame.setJMenuBar(MenuBar);
        MainFrame.setIconImage(new ImageIcon("Resources/Images/Icon.png").getImage());
        MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MainFrame.setVisible(true);
//        MainFrame.addWindowListener(new WindowAdapter() {
//            @Override
//            public void windowClosing(WindowEvent e) {
//               
//            }
//        });

//here i am adding the ingrediants panel temporarily for now
        //  MainFrame.add(new IngrediantPanel());
        //MainFrame.add(new NotesPanel());
        MainFrame.add(new DoughCreator());
        // MainFrame.add(new DoughInfoPanel());
        MainFrame.repaint();

    }

    public static class DoughCreator extends JPanel {

        public DoughCreator() {
            Border GrayLine = BorderFactory.createLineBorder(Color.LIGHT_GRAY);

            super.setBounds(DoughTracker.dimensions.doughCreatorX, DoughTracker.dimensions.doughCreatorY, DoughTracker.dimensions.doughCreatorWidth, DoughTracker.dimensions.doughCreatorHieght);
            super.setLayout(null);
            super.setBorder(GrayLine);

            JLabel NameLabel = new JLabel("Dough Name:");
            NameLabel.setFont(new Font("Ariel", Font.BOLD + Font.ITALIC, 32));
            NameLabel.setBounds(25, 25, 250, 50);
            super.add(NameLabel);

            JLabel doughName = new JLabel("Gluten Free dough test label");
            doughName.setFont(new Font("Ariel", Font.PLAIN + Font.ITALIC, 32));
            doughName.setBounds(260, 25, DoughTracker.dimensions.doughCreatorWidth - 300, 50);
            super.add(doughName);

            JTextField doughTypeTextField = new JTextField("");
            doughTypeTextField.setFont(new Font("Ariel", Font.PLAIN, 32));
            doughTypeTextField.setOpaque(false);
            doughTypeTextField.setToolTipText("The name of the Dough...");
            doughTypeTextField.setBounds(260, 25, DoughTracker.dimensions.doughCreatorWidth - 300, 50);
            doughTypeTextField.setBorder(GrayLine);
            doughTypeTextField.setEditable(true);
            doughTypeTextField.setVisible(false);
            super.add(doughTypeTextField);

            JTable ingrediantsTable = new JTable() {
                @Override
                public boolean isCellEditable(int row, int column) {

                    return true;
                }
            };
            ingrediantsTable.setGridColor(Color.LIGHT_GRAY);
            ingrediantsTable.getTableHeader().setFont(new Font("Arial", Font.BOLD, 16));
            ingrediantsTable.setFont(new Font("Ariel", Font.PLAIN, 16));
            // MainWindowTable.setDefaultRenderer(Object.class, new MyCellRenderer());
            ingrediantsTable.setRowHeight(25);
            ingrediantsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            ingrediantsTable.getTableHeader().setPreferredSize(new Dimension(300, 40));
            ingrediantsTable.setFocusable(false);

            DefaultTableModel ingrediantsTableModel = new DefaultTableModel();
            ingrediantsTableModel.addColumn("Ingrediant");
            ingrediantsTableModel.addColumn("Amount");
            ingrediantsTableModel.addColumn("Unit");

            ingrediantsTable.setModel(ingrediantsTableModel);

            String[] values = new String[]{"1", "2", "3"};

            TableColumn col = ingrediantsTable.getColumnModel().getColumn(0);
            col.setCellEditor(new MyComboBoxEditor(values));
            col.setCellRenderer(new MyComboBoxRenderer(values));

            JScrollPane ingrediantsTableScrollPane = new JScrollPane(ingrediantsTable);
            ingrediantsTableScrollPane.setBounds(25, 100, DoughTracker.dimensions.doughCreatorWidth - 100, DoughTracker.dimensions.doughCreatorHieght - 250);
            ingrediantsTableScrollPane.setVisible(true);
            ingrediantsTableScrollPane.setBackground(Color.WHITE);
            super.add(ingrediantsTableScrollPane);

            JButton addIngrediantButton = new JButton("+");
            addIngrediantButton.setFont(new Font("Arial", Font.BOLD, 18));
            addIngrediantButton.setToolTipText("Add an Ingrediant");
            addIngrediantButton.setOpaque(false);
            addIngrediantButton.setContentAreaFilled(true);
            addIngrediantButton.setBorderPainted(false);
            addIngrediantButton.setFocusable(false);
            addIngrediantButton.setBounds(DoughTracker.dimensions.doughCreatorWidth - 65, 100, 50, 50);
            addIngrediantButton.setVisible(true);
            addIngrediantButton.setEnabled(true);
            addIngrediantButton.addActionListener((ActionEvent e) -> {
                ingrediantsTableModel.addRow(new Object[]{"", ""});
            });

            super.add(addIngrediantButton);

            JButton removeIngrediantButton = new JButton("-");
            removeIngrediantButton.setFont(new Font("Arial", Font.BOLD, 18));
            removeIngrediantButton.setToolTipText("Add an Ingrediant");
            removeIngrediantButton.setOpaque(false);
            removeIngrediantButton.setContentAreaFilled(true);
            removeIngrediantButton.setBorderPainted(false);
            removeIngrediantButton.setFocusable(false);
            removeIngrediantButton.setBounds(DoughTracker.dimensions.doughCreatorWidth - 65, 160, 50, 50);
            removeIngrediantButton.setVisible(true);
            removeIngrediantButton.setEnabled(true);
            removeIngrediantButton.addActionListener((ActionEvent e) -> {
                if (ingrediantsTable.getSelectedRow() != -1) {
                    ingrediantsTableModel.removeRow(ingrediantsTable.getSelectedRow());
                } else {
                    Toolkit.getDefaultToolkit().beep();
                }
            });
            super.add(removeIngrediantButton);

            JLabel totalDoughWieght, totalWaffles, gramsPerDoughBall, borderLabel;

            totalDoughWieght = new JLabel("Dough Wieght:");
            totalDoughWieght.setFont(new Font("Ariel", Font.BOLD, 16));
            totalDoughWieght.setBounds(35, DoughTracker.dimensions.doughCreatorHieght - 140, 175, 30);
            super.add(totalDoughWieght);

            gramsPerDoughBall = new JLabel("Grams Per dough Ball:");
            gramsPerDoughBall.setFont(new Font("Ariel", Font.BOLD, 16));
            gramsPerDoughBall.setBounds(35, DoughTracker.dimensions.doughCreatorHieght - 95, 175, 30);
            super.add(gramsPerDoughBall);

            totalWaffles = new JLabel("Total Waffles:");
            totalWaffles.setFont(new Font("Ariel", Font.BOLD, 16));
            totalWaffles.setBounds(35, DoughTracker.dimensions.doughCreatorHieght - 50, 175, 30);
            super.add(totalWaffles);

            JTextField gramsPerDoughAnswerTextField, totalWieghtAnswerTextField, totalWafflesAnswerTextField;

            totalWieghtAnswerTextField = new JTextField("");
            totalWieghtAnswerTextField.setFont(new Font("Ariel", Font.PLAIN, 16));
            totalWieghtAnswerTextField.setBackground(Color.white);
            totalWieghtAnswerTextField.setToolTipText("The Wieght of the entire dough");
            totalWieghtAnswerTextField.setBounds(225, DoughTracker.dimensions.doughCreatorHieght - 140, 75, 30);
            totalWieghtAnswerTextField.setBorder(GrayLine);
            totalWieghtAnswerTextField.setEditable(false);
            totalWieghtAnswerTextField.setEnabled(true);
            totalWieghtAnswerTextField.setVisible(true);
            super.add(totalWieghtAnswerTextField);

            gramsPerDoughAnswerTextField = new JTextField("35");
            gramsPerDoughAnswerTextField.setFont(new Font("Ariel", Font.PLAIN, 16));
            gramsPerDoughAnswerTextField.setBackground(Color.white);
            gramsPerDoughAnswerTextField.setToolTipText("The Wieght in grams of each dough ball before it is baked");
            gramsPerDoughAnswerTextField.setBounds(225, DoughTracker.dimensions.doughCreatorHieght - 95, 75, 30);
            gramsPerDoughAnswerTextField.setBorder(GrayLine);
            gramsPerDoughAnswerTextField.setEditable(true);
            gramsPerDoughAnswerTextField.setEnabled(true);
            gramsPerDoughAnswerTextField.setVisible(true);
            super.add(gramsPerDoughAnswerTextField);

            totalWafflesAnswerTextField = new JTextField("");
            totalWafflesAnswerTextField.setFont(new Font("Ariel", Font.PLAIN, 16));
            totalWafflesAnswerTextField.setBackground(Color.white);
            totalWafflesAnswerTextField.setToolTipText("Approxamite amount of waffles each dough will produce");
            totalWafflesAnswerTextField.setBounds(225, DoughTracker.dimensions.doughCreatorHieght - 50, 75, 30);
            totalWafflesAnswerTextField.setBorder(GrayLine);
            totalWafflesAnswerTextField.setEditable(false);
            totalWafflesAnswerTextField.setEnabled(true);
            totalWafflesAnswerTextField.setVisible(true);
            super.add(totalWafflesAnswerTextField);

            borderLabel = new JLabel();
            borderLabel.setFont(new Font("Ariel", Font.BOLD, 16));
            borderLabel.setBorder(GrayLine);
            borderLabel.setBounds(25, DoughTracker.dimensions.doughCreatorHieght - 140, 350, 125);
            super.add(borderLabel);

        }

        class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {

            public MyComboBoxRenderer(String[] items) {
                super(items);
            }

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                    boolean hasFocus, int row, int column) {
                if (column == 0) {
                    if (isSelected) {
                        setForeground(table.getSelectionForeground());
                        setBackground(table.getSelectionBackground());
                        setSelectedItem(value);
                    } else {
                        setForeground(table.getForeground());
                        setBackground(table.getBackground());

                    }
                }

                return this;
            }
        }

        class MyComboBoxEditor extends DefaultCellEditor {

            public MyComboBoxEditor(String[] items) {
                super(new JComboBox(items));
            }
        }
    }

    public static class Dimensions {

    int windowWidth;
    int windowHieght;

    int ingrediantPanelX;
    int ingrediantPanelY;
    int ingrediantPanelWidth;
    int ingrediantPanelHieght;

    int notesPanelX;
    int notesPanelY;
    int notesPanelWidth;
    int notesPanelHieght;

    int doughCreatorX;
    int doughCreatorY;
    int doughCreatorWidth;
    int doughCreatorHieght;

    int doughInfoPanelX;
    int doughInfoPanelY;
    int doughInfoPanelWidth;
    int doughInfoPanelHieght;

    public Dimensions() {

        windowWidth = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
        windowHieght = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;

        ingrediantPanelX = 50;
        ingrediantPanelY = 50;
        ingrediantPanelWidth = windowWidth / 3;
        ingrediantPanelHieght = windowHieght - 125;

        notesPanelWidth = windowWidth / 4;
        notesPanelHieght = windowHieght / 3;
        notesPanelX = windowWidth - notesPanelWidth - 50;
        notesPanelY = windowHieght - notesPanelHieght - 75;

        doughCreatorX = 50;
        doughCreatorY= 50;
        doughCreatorWidth = windowWidth /2-100;
        doughCreatorHieght = windowHieght-125;

        doughInfoPanelX = doughCreatorX+doughCreatorWidth+50;
        doughInfoPanelY = 50;
        doughInfoPanelWidth = windowWidth /2-50;
        doughInfoPanelHieght = windowHieght-125;
    }

     public int getDoughInfoPanelX() {
        return doughInfoPanelX;
    }

    public int getDoughInfoPanelY() {
        return doughInfoPanelY;
    }

    public int getDoughInfoPanelWidth() {
        return doughInfoPanelWidth;
    }

    public int getDoughInfoPanelHieght() {
        return doughInfoPanelHieght;
    }

        public int getdoughCreatorX() {
        return doughCreatorX;
    }

    public int getdoughCreatorY() {
        return doughCreatorY;
    }

    public int getdoughCreatorWidth() {
        return doughCreatorWidth;
    }

    public int getdoughCreatorHieght() {
        return doughCreatorHieght;
    }

    public int getNotesPanelX() {
        return notesPanelX;
    }

    public int getNotesPanelY() {
        return notesPanelY;
    }

    public int getNotesPanelWidth() {
        return notesPanelWidth;
    }

    public int getNotesPanelHieght() {
        return notesPanelHieght;
    }

    public int getIngrediantPanelX() {
        return ingrediantPanelX;
    }

    public int getIngrediantPanelY() {
        return ingrediantPanelY;
    }

    public int getIngrediantPanelWidth() {
        return ingrediantPanelWidth;
    }

    public int getIngrediantPanelHieght() {
        return ingrediantPanelHieght;
    }

    public int getWindowWidth() {
        return windowWidth;
    }

    public int getWindowHieght() {
        return windowHieght;
    }
}

}

Renderer does not use latest value from model.

I thoought the actual value from the combobox is stored in the table model and can be obtained as any data stored in the table model itself?

OK, I've loaded and run your code.
The problem definitely seems to be in the shared renderer.
If you simply comment out the line (~135) that sets the renderer then the table uses a default text field renderer and everything works correctly.

When swing refreshes the table it uses your renderer (of which there is only one instance) to paint all the cells in col 0 that are not currently being edited. That renderer paints exactly the same thing into each of those cells.
You need the renderer to use the actual value from the table model, which is passed into the getTableCellRendererComponent method, but ignored in your code.

Just for fun I added a setSelectedItem(value);call into that method. That way the combo box has the right item selected when the renderer is called for each cell.

However it does not work when the cell hasn't had a value set yet. In that case you just get the value left over from the previous call, so to make it work you need to initialise each cell to a valid value from the combo box when the new row is added.

Man I'm Dumb,

Thanks,

How I have a question kinda related, How do i make the combobox disapear again if a user doesant finished selecting an item and does somthing else?

You need to click the table again for the combobox to dissapear...

Not sure exactly what behaviour you want, but if you set the editor but leave the default renderer then the combo box only shows when a cell is being edited and all the other cells just show their current value. That would be a normal behaviour in my opinion.

ps. Not dumb at all. We've all done stuff like that. Fortunately you could harness the power of castle DaniWeb.

Thank you for your help sir,

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.