(转)为什么水平滚动条显示不了

链接地址:http://zhidao.baidu.com/link?url=6id6U8yUAy-Vw_vjMo3yKl5bJxztgiusfpHeZQhjnQapI6tUZqmbMDzDfoWPqUzoFNG3V2h9evIb7ph-OTt35K

 

private JTabbedPane createNavigationPanel() { // 创建导航标签面板的方法   JTabbedPane tabbedPane = new JTabbedPane();     JPanel databasePanel=new JPanel();//人员档案总览   tabbedPane.addTab("人员档案查询",databasePanel);   JLabel label=new JLabel("选择查询条件:");   String[] comboboxtitle1={"姓名","性别","出生日期","籍贯","家庭住址"};   String[] comboboxtitle2={"等于","包含"};   JComboBox conditionBox1=new JComboBox();   conditionBox1.setModel(new DefaultComboBoxModel(comboboxtitle1));   JComboBox conditionBox2=new JComboBox();   conditionBox2.setModel(new DefaultComboBoxModel(comboboxtitle2));   JTextField textfield=new JTextField(10);   JButton buttonSelect=new JButton("查询");   JButton buttonShowAll=new JButton("显示全部数据");   databasePanel.add(label,BorderLayout.NORTH);   databasePanel.add(conditionBox1,BorderLayout.NORTH);   databasePanel.add(conditionBox2,BorderLayout.NORTH);   databasePanel.add(textfield,BorderLayout.NORTH);   databasePanel.add(buttonSelect,BorderLayout.NORTH);   databasePanel.add(buttonShowAll,BorderLayout.NORTH);   String[] tableHead={"人员代码","姓名","性别","出生日期","身份证号","籍贯","家庭住址","联系电话","备注"};   DefaultTableModel defaulttablemodel=new DefaultTableModel();   defaulttablemodel.setColumnIdentifiers(tableHead);   DefaultTableColumnModel defaulttablecolumnmodel=new DefaultTableColumnModel();   JTable databaseTable=new JTable(defaulttablemodel);   databaseTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);   databaseTable.setEnabled(false);//设置JTable无法修改   JScrollPane sDatabaseTable=new JScrollPane(databaseTable);   databasePanel.add(sDatabaseTable,BorderLayout.CENTER);     JPanel changePanel=new JPanel();//人员档案增加、删除、修改   tabbedPane.addTab("人员档案管理",changePanel);   return tabbedPane; }

 

提问者采纳

 
JTable databaseTable=new JTable(defaulttablemodel);  databaseTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);  databaseTable.setEnabled(false);//设置JTable无法修改  JScrollPane sDatabaseTable=new JScrollPane(databaseTable);//添加滚动条  databasePanel.add(sDatabaseTable,BorderLayout.CENTER); 

 

posted @ 2013-12-30 20:44  菜鸟搞IT  阅读(353)  评论(0编辑  收藏  举报