自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在表格中Swing增加列表框

開(kāi)發(fā) 后端
本文介紹在表格中Swing增加列表框,首先獲得列表對(duì)象,在設(shè)置表列編輯,將下拉列表框作為默認(rèn)列編輯對(duì)象設(shè)置到表列編輯對(duì)象中。

Swing增加下拉列表框

在表格的一列中Swing增加下拉列表框,首先獲得列表對(duì)象,在設(shè)置表列編輯,將下拉列表框作為默認(rèn)列編輯對(duì)象設(shè)置到表列編輯對(duì)象中

  1. importjava.awt.BorderLayout;  
  2. importjava.awt.Dimension;  
  3.  
  4. importjavax.swing.JFrame;  
  5. importjavax.swing.JPanel;  
  6. importjavax.swing.JScrollPane;  
  7. importjava.awt.Rectangle;  
  8. importjavax.swing.JTable;  
  9. importjavax.swing.table.TableColumn;  
  10. importjavax.swing.DefaultCellEditor;  
  11. importjavax.swing.JComboBox;  
  12. importjavax.swing.JCheckBox;  
  13.  
  14. publicclassJComboBoxSecondextendsJFrame{  
  15. JPanelcontentPane;  
  16. JScrollPanejScrollPane1=newJScrollPane();  
  17. Object[][]objContent={{"Tom","Hanks","Java","24","true"},{"Ben","John",  
  18. "Java","25","true"},{"Michael","Fred","Java","26","true"},  
  19. {"Steve","Bell","Java","27","true"},  
  20. {"Jim","Lan","Java","29","true"}  
  21. };  
  22. Object[]objHead={"名字","姓氏","技能","年齡","是否屬實(shí)"};  
  23. JTablejTable1=newJTable(objContent,objHead);  
  24. JComboBoxjComBo=newJComboBox();  
  25. JCheckBoxjCheck=newJCheckBox("");  
  26. publicJComboBoxSecond(){  
  27. try{  
  28. setDefaultCloseOperation(EXIT_ON_CLOSE);  
  29. jbInit();  
  30. }catch(Exceptionexception){  
  31. exception.printStackTrace();  
  32. }  
  33. }  
  34.  
  35. /**  
  36. *Componentinitialization.  
  37. *  
  38. *@throwsjava.lang.Exception  
  39. */  
  40. privatevoidjbInit()throwsException{  
  41. contentPane=(JPanel)getContentPane();  
  42. contentPane.setLayout(null);  
  43. setSize(newDimension(467,401));  
  44. setTitle("FrameTitle");  
  45. jScrollPane1.setBounds(newRectangle(11,20,442,337));  
  46. jComBo.addItem("Java");  
  47. jComBo.addItem("Orcale");  
  48. jComBo.addItem("Linux");  
  49. jComBo.addItem("Unix");  
  50. jComBo.addItem("C#");  
  51.  
  52. TableColumntableCol=jTable1.getColumnModel().getColumn(2);  
  53. tableCol.setResizable(false);  
  54. TableColumntableColCheck=jTable1.getColumnModel().getColumn(4);  
  55. tableCol.setCellEditor(newDefaultCellEditor(jComBo));  
  56. tableColCheck.setCellEditor(newDefaultCellEditor(jCheck));  
  57. contentPane.add(jScrollPane1);  
  58. jScrollPane1.getViewport().add(jTable1);  
  59. }  

以上是Swing增加下拉列表框,希望對(duì)大家有用

【編輯推薦】

  1. SwingUtilities提供兩個(gè)方法
  2. 淺談Swing中的渲染器接口
  3. Swing組件中的渲染器Renderer
  4. 淺析Swing線(xiàn)程中的LookupEvent
  5. Swing任務(wù)在Swing線(xiàn)程中執(zhí)行
責(zé)任編輯:佚名 來(lái)源: 電子工業(yè)出版社
相關(guān)推薦

2012-01-17 14:01:33

JavaSwing

2010-01-26 09:27:47

Android列表框

2009-07-16 08:53:03

Swing任務(wù)Swing線(xiàn)程

2012-01-17 14:09:54

JavaSwing

2024-02-27 09:24:50

PyQt6中列表框樹(shù)形視圖

2022-04-26 16:56:44

CISA漏洞攻擊

2012-08-09 11:20:40

Swing

2023-01-04 07:46:10

單選按鈕雙擊效果

2012-03-08 11:23:09

jQuery Mobi

2009-07-17 16:41:48

actionPerfoSwing

2009-07-10 10:19:57

JFormattedTSwing

2009-07-17 16:49:18

lookandfeelSwing

2009-07-14 16:07:59

調(diào)用JavaFX代碼Swing程序

2009-07-15 09:59:11

Metal觀感Swing

2011-05-04 15:21:20

swing

2009-07-16 09:54:44

LookupEventSwing線(xiàn)程

2009-07-17 16:32:34

Timer對(duì)象Swing

2020-02-12 12:28:29

python列表數(shù)據(jù)類(lèi)型

2009-08-06 17:34:27

地址欄控件C#記憶功能

2012-12-25 10:48:35

IBMdW
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)