Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String args[]) {
- JFrame frame = new JFrame();
- frame.setSize(450, 250);
- JTable table = new JTable(2, 1);
- TableColumn testColumn = table.getColumnModel().getColumn(0);
- JComboBox<String> comboBox = new JComboBox<String>();
- comboBox.addItem("Item1");
- comboBox.addItem("Item2");
- comboBox.addItem("Item3");
- testColumn.setCellEditor(new DefaultCellEditor(comboBox));
- comboBox.addItemListener(new ItemListener(){
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED){
- System.out.println(table.getValueAt(0, 0));
- }
- }
- });
- frame.add(table);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(true);
- }
Add Comment
Please, Sign In to add comment