谁有在表格中显示图片的代码啊,我的总是无法显示
比如说给个2行2列的表格,在每个单元格中显示一张图片。

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【redking123】截止到2008-06-23 12:26:10的历史汇总数据(不包括此帖):
    发帖数:3                  发帖分:50                 
    结贴数:2                  结贴分:30                 
    未结数:1                  未结分:20                 
    结贴率:66.67 %            结分率:60.00 %            
    楼主加油
      

  2.   

    <table>
    <tr>
    <td>
    <img  src='<c:out value="${pageContext.request.contextPath}"/>/images/ask1.jpg' >
    </td>
    <td>
    <img  src='<c:out value="${pageContext.request.contextPath}"/>/images/ask2.jpg' >
    </td>
    </tr>
    <tr>
    <td>
    <img  src='<c:out value="${pageContext.request.contextPath}"/>/images/ask3.jpg' >
    </td>
    <td>
    <img  src='<c:out value="${pageContext.request.contextPath}"/>/images/ask4.jpg' >
    </td>
    </tr>
    </table>
      

  3.   

    不是JSP中的,是j2se中的问题!
      

  4.   

    表格中的TableCellRenderer,由于TableCellRenderer默认是以JLabel作为单元格的,你先继承JLabel并写一个在其上绘制图像的函数,用这个继承来的JLabel重写getTableCellRendererComponent
      

  5.   

    JDK的例子里面有所有的控件操作。你可以去看一下。代码和gui都有。
      

  6.   

    如果是网页中显示,见楼上。
    如果是 Swing JTable 中显示,参考 你的JDK安装目录\demo\jfc\SwingSet2\SwingSet2.jar
      

  7.   


    看看这样行不行JTable jtable=new JTable();
    jtable.setValueAt(Object aValue, int row, int column);
    注:
      Object aValue:图片对象
      int row :行数
      int column:列数
      

  8.   

    为什么不用gridlayout呢, 比jtable简单多了,如下
    public JPanel createCenterPane() { JPanel center_panel = new JPanel(); center_panel.setLayout(new GridLayout(2, 4)); // System.out.println(System.getProperty("user.dir")); //currentlocation

    ImageIcon buttonIcon = new ImageIcon("pics/home.png",
    JButton button1 = new JButton("Home", buttonIcon);
    button1.addActionListener(this);
                    ......
    ImageIcon buttonIcon8 = new ImageIcon("pics/Journal.png",
    "button for Journal");
    button8 = new JButton("Journal", buttonIcon8);
    button8.addActionListener(this); center_panel.add(button1);
                    .....
    center_panel.add(button8); return center_panel;
    }