我在mainPanel(主面板上)加了一个JPanel(DrawPanel)面板,用于显示地图,地图画在mapPane(JMapPane类型,GeoTools中的一种面板)上,现在当我触发了我要写的那个函数后,我在里面想把MapPanel显示出来 ,但不知道怎么都显示不出来,我写的是Application的程序不是Applet类型的。
代码如下:
private void jMenuItem_OpenFileActionPerformed(java.awt.event.ActionEvent evt) // 触发显示地图的函数  
{                                                   
        try {
            // TODO add your handling code here:
            file_open = getShapeFile();
            jButton_ZoomIn.setEnabled(true);
            jButton_ZoomOut.setEnabled(true);
            jButton_ZoomMove.setEnabled(true);
            shapefile = new ShapefileDataStore(file_open.toURL());
            typeName = shapefile.getTypeNames()[0];
            featureSource = shapefile.getFeatureSource();
            schema =featureSource.getSchema();
            crs = schema.getGeometryDescriptor()
                .getCoordinateReferenceSystem();            map = new DefaultMapContext(crs);
            style = createStyle(file_open, schema);
            map.addLayer(featureSource, style);
            mapPane = new JMapPane(new StreamingRenderer(), map);
             try {
            mapPane.setMapArea(map.getLayerBounds());
               } catch (IOException ex) {
            System.out.println(ex.toString());
            }
            DrawPanel.setSize(600,400);//前面的都是无关紧要的代码,主要从下面这里开始,不知道怎么就是显示不了,好像触发后DrawPanel面板没了一样。
            DrawPanel.setLayout(new BorderLayout());
            DrawPanel.add(mapPane,BorderLayout.NORTH);//添加mapPanel
            /*
            mainPanel.add(jPanel_ToolBar,BorderLayout.NORTH);
             mainPanel.add(mapPane,BorderLayout.CENTER);
            mainPanel.updateUI();*/
            } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }
说明:
DrawPanel是通过可视化的IDE加到主面板(mainPanel)上的面板。
好像触发这个函数后DrawPanel面板变成了一条线了。高度差不多为0了。
希望哪个大侠帮帮忙,谢谢了。     
刚建的号,没分,不好意思啊,希望哪个能帮下忙,谢谢了