how to add jcombobox to jtable column in netbeans

前端 未结 1 1540
误落风尘
误落风尘 2021-02-09 17:02

\"enter

I want to add jcombobox to jtable please someone explain me how could i do that in

相关标签:
1条回答
  • 2021-02-09 17:48

    Add a JComboBox by dragging and dropping outside the frame or panel.So that it will be added to OtherComponents in the Navigator View

    enter image description here

    Add whatever contents you want to add by double clicking the combobox from Navaigator View

    Then rightclick on JTable and click TableContents

    enter image description here

    In the Dialog select Columns Tab(1) and select the column(2) you want to add the combobox to.

    Then Click on the button near to the Editor[Ref screenshot (3)]

    Then in the editor dialog Choose Custom Code from the dropdown(4)

    Then put the following(5)

    new DefaultCellEditor(jComboBox1)//jComboBox1 is the variable name of combobox 
    

    enter image description here

    Then Click ok and close and make sure you import import javax.swing.DefaultCellEditor; or do a Ctrl+Shift+I to add the necessary imports

    After that If you run and click on column 2 you'll get this output

    enter image description here

    0 讨论(0)
提交回复
热议问题