new ImageIcon("c:\1.gif");
改成new ImageIcon("C:\\1.gif");
还有,因为安全机制applet在浏览器中运行时不能直接访问本地文件,图像还是可能显示不了

解决方案 »

  1.   

    不能更改,还不能访问吗?
    new ImageIcon("C:\\1.gif");也不行
      

  2.   

    不要用绝对路径,你可以试试,将图片打成pic.jar(picture/1.gif....),
    引入pic.jarimport javax.swing.*;
    import java.awt.*;
    import picture.*;public class TJSplitPane extends JApplet {
        static int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT;
        static int VERTSPLIT = JSplitPane.VERTICAL_SPLIT;
        boolean continuousLayout = true;
        Icon icon1 = new ImageIcon("1.gif");
        Icon icon2 = new ImageIcon("2.gif");
        Icon icon3 = new ImageIcon("3.gif");    public void init() {
            // 1. Create a label to display icon1 and add it to a scroll pane.    
            JLabel label1 = new JLabel(icon1);
            JScrollPane topLeftComp = new JScrollPane(label1);
            
            // 2. Create another lable to display icon2 and add it to another scroll pane.
            JLabel label2 = new JLabel(icon2);
            JScrollPane bottomLeftComp = new JScrollPane(label2);
            
            // 3. Create a third label to display icon3 and add it to one more scroll pane.
            JLabel label3 = new JLabel(icon3);
            JScrollPane rightComp = new JScrollPane(label3);
        
            // 4. Add the scroll panes displaying icon1 and icon2 to a split pane.
            JSplitPane splitPane1 = new JSplitPane(VERTSPLIT,
                                              continuousLayout,
                                              topLeftComp,
                                              bottomLeftComp);
            splitPane1.setOneTouchExpandable(true); // Provide a collapse/expand widget.
            splitPane1.setDividerSize(2); // Divider size.
            splitPane1.setDividerLocation(0.5); // Initial location of the divider.
            
            // 5. Add the previous split pane and the scroll pane displaying 
            // icon3 to an outer split pane.
            JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT,   
                                              continuousLayout,                                     
                                              splitPane1, // left comp
                                              rightComp);
            splitPane2.setOneTouchExpandable(true); // Provide a collapse/expand widget.
            splitPane2.setDividerLocation(0.4); // divider size 
            splitPane2.setDividerSize(2); // Initial location of the divider.
               
            // 6. Add the outer split pane to the content pane of the applet.                             
            getContentPane().add(splitPane2);                                 
        }
    }
      

  3.   

    用this.class.getresource(new ImageIcon("image\1.gif"));
    将图片放到 .java一起的image文件。
    就可以了。
      

  4.   

    我把它们打成一个包*.jar,也还是不能看到图片,而且,划分区域也不是按照我指定的划分的,全部集中到了左上角,并且用appletviewer也不能看到图片.请大侠帮忙!!