[英]how to add different JComboBox items in a Column of a JTable in Swing
[英]how to add jcombobox to jtable column in netbeans
我想將jcombobox添加到jtable請有人解釋我怎么能在netbeans中做到這一點
通過在框架或面板外拖放來添加JComboBox
。因此它將被添加到Navigator視圖中的OtherComponents
通過雙擊Navaigator View中的組合框添加要添加的任何內容
然后右鍵單擊JTable
並單擊TableContents
在對話框中選擇Columns
選項卡(1)並選擇要添加組合框的列(2)。
然后單擊編輯器附近的按鈕[參考屏幕截圖(3)]
然后在編輯器對話框中從下拉列表中選擇Custom Code
(4)
然后把以下(5)
new DefaultCellEditor(jComboBox1)//jComboBox1 is the variable name of combobox
然后單擊確定並關閉並確保導入import javax.swing.DefaultCellEditor;
或者Ctrl+Shift+I
添加必要的導入
之后如果您運行並單擊第2列,您將獲得此輸出
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.