| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2388 人关注过本帖
标题:关于无法解析javax.swing.JTable的问题
只看楼主 加入收藏
枫xby
Rank: 5Rank: 5
等 级:职业侠客
威 望:8
帖 子:82
专家分:371
注 册:2014-10-19
结帖率:71.43%
收藏
已结贴  问题点数:10 回复次数:2 
关于无法解析javax.swing.JTable的问题
/*
 * Datail.java
 *
 * Created on __DATE__, __TIME__
 */

package readerMange;

import java.util.Iterator;
import java.util.List;

import javax.swing.table.DefaultTableModel;

import com.sun.awt.AWTUtilities;

import dbConntect.Datause;




/**
 *
 * @author  __USER__
 */
@SuppressWarnings("serial")
public class Datail extends javax.swing.JFrame {
   
    /** Creates new form Datail */
    public Datail() {
        dao =new Datause();
        initComponents();
        AWTUtilities.setWindowOpacity(this, 0.7f);
        //AWTUtilities.setWindowOpaque(this, false);
    }

    private void initComponents() {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
                    .getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setUndecorated(true);

        jTable1.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 14));
        dftm = (DefaultTableModel) jTable1.getModel();
        columnNames = new String[] { "姓名", "书一","详情" ,"书二","详情","书三","详情","书四","详情"};
        dftm.setColumnIdentifiers(columnNames);
        jScrollPane1.setViewportView(jTable1);

        jButton1.setText("\u9000\u51fa");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("\u5237\u65b0");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
                jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 800,
                Short.MAX_VALUE).addGroup(
                jPanel1Layout.createSequentialGroup().addGap(202, 202, 202)
                        .addComponent(jButton2,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 140,
                                javax.swing.GroupLayout.PREFERRED_SIZE).addGap(
                                162, 162, 162).addComponent(jButton1,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 140,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(156, Short.MAX_VALUE)));
        jPanel1Layout
                .setVerticalGroup(jPanel1Layout
                        .createParallelGroup(
                                javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(
                                jPanel1Layout
                                        .createSequentialGroup()
                                        .addComponent(
                                                jScrollPane1,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                385,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(
                                                javax.swing.,
                                                18, Short.MAX_VALUE)
                                        .addGroup(
                                                jPanel1Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(
                                                                jButton2,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                44,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(
                                                                jButton1,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                39,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addContainerGap()));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
                getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addComponent(jPanel1,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));

        pack();
    }// </editor-fold>
    //GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        initTable();
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        this.dispose();
    }
   
    @SuppressWarnings( { "unchecked" })
    private void initTable() {
        List ul = dao.getDatails();
        Iterator it = ul.iterator();
        String[] data = new String[9];
        dftm.setDataVector(null, columnNames);
        while (it.hasNext()) {
            List userlist = (List) it.next();
            data[0] = (String) userlist.get(0);
            data[1] = (String) userlist.get(1);
            if(((String)userlist.get(2)).equals("0")){
                data[2]="已还";
            }else if(((String)userlist.get(2)).equals("1")){
                data[2]="未还";
            }else {
                data[2]=null;
            }
            data[3] = (String) userlist.get(3);
            
            if(((String)userlist.get(4)).equals("0")){
                data[4]="已还";
            }else if(((String)userlist.get(4)).equals("1")){
                data[4]="未还";
            }else {
                data[4]=null;
            }
            
            data[5] = (String) userlist.get(5);
            
            if(((String)userlist.get(6)).equals("0")){
                data[6]="已还";
            }else if(((String)userlist.get(6)).equals("1")){
                data[6]="未还";
            }else {
                data[6]=null;
            }
            
            data[7] = (String) userlist.get(7);
            
            if(((String)userlist.get(8)).equals("0")){
                data[8]="已还";
            }else if(((String)userlist.get(8)).equals("1")){
                data[8]="未还";
            }else {
                data[8]=null;
            }
            dftm.addRow(data);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Datail().setVisible(true);
            }
        });
    }

    //GEN-BEGIN:variables
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private Datause dao;
    private String[] columnNames;
    private DefaultTableModel dftm;
    // End of variables declaration//GEN-END:variables

}
搜索更多相关主题的帖子: package public import 
2015-06-09 20:34
凌风zx
Rank: 8Rank: 8
来 自:万灵娱乐城
等 级:蝙蝠侠
威 望:7
帖 子:88
专家分:790
注 册:2015-4-11
收藏
得分:10 
无法解析是几个意思 这个词可不能乱用

报错了吗 错误信息是什么

此程序也不全啊 看不到效果  dbConntect.Datause:这是你自己写的吧

初出茅庐
2015-06-10 09:37
枫xby
Rank: 5Rank: 5
等 级:职业侠客
威 望:8
帖 子:82
专家分:371
注 册:2014-10-19
收藏
得分:0 
回复 2楼 凌风zx
就是导入到Eclipse错误 也许是jdk版本不同导致错误了
2015-06-10 21:43
快速回复:关于无法解析javax.swing.JTable的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029124 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved