2 Graphics_hardware_resource or Device objects have not been destructed

958
0
03-19-2018 10:32 PM
prb
by
New Contributor

Hi ,I'm trying to bring the offline map on the Right side of the Split pane ,i can't able to get ,only Split pane is displaying ,It should Display Offline map also on the Split pane ,and I'm getting "2 Graphics_hardware_resource or Device objects have not been destructed"

package demoApp;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
//import javafx.scene.text.Font;
import javafx.scene.text.Text;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;

import com.esri.arcgisruntime.loadable.LoadStatus;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.MobileMapPackage;
import com.esri.arcgisruntime.mapping.view.MapView;

public class MainMethod
{
private static MapView mapView;

private static void initAndShowGUI()
{

System.out.println("Control enters into the initAndShowGUI() ");
// This method is invoked on the EDT thread
JFrame frame = new JFrame("Swing and JavaFX");

frame = new JFrame();

JSplitPane splitPane = new JSplitPane();
frame.getContentPane().add(splitPane, BorderLayout.CENTER);
JPanel panel = new JPanel();
splitPane.setRightComponent(panel);


JPanel panel_1 = new JPanel();
// panel_1.setForeground(Color.WHITE);
splitPane.setLeftComponent(panel_1);
panel_1.setLayout(null);

// panel_1.setVisible(true);
final JFXPanel fxPanel = new JFXPanel();
// JComponent jfxPanel = null;
// JFXPanel = new JFXPanel();
fxPanel .setPreferredSize(new Dimension(600, 600));
panel.add(fxPanel);
panel.setSize(300, 200);
//panel.setVisible(true);
System.out.println("Control enters into the initAndShowGUI() 2 ");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
System.out.println("Control enters into the initAndShowGUI() 3 ");

// mapView = new MapView();


Platform.runLater(new Runnable()

{


@Override
public void run()
{

setupMobileMap();
initFX(fxPanel);
System.out.println("Control enters into the run() ");
}
});
}

private static void initFX(JFXPanel fxPanel)
{
// This method is invoked on the JavaFX thread
Scene scene = createScene();
//Scene scene =setupMap();


fxPanel.setScene(scene);
System.out.println("Control enters into the initFX() ");
}


private static void setupMobileMap() {

if (mapView != null)
{
System.out.println("Control enters into the setupMobileMap() ");
String mmpkFile = "./India.mmpk";
final MobileMapPackage mapPackage = new MobileMapPackage(mmpkFile);
mapPackage.addDoneLoadingListener(() -> {
if (mapPackage.getLoadStatus() == LoadStatus.LOADED && mapPackage.getMaps().size() > 0) {
mapView.setMap(mapPackage.getMaps().get(0));
}
else
{
setupMap();
}
});
mapPackage.loadAsync();
}
}

private static void setupMap()
{
System.out.println("Control enters into the setupMap() ");
/*Group root = new Group();
Scene scene = new Scene(root, Color.ALICEBLUE);*/

if (mapView != null) {
Basemap.Type basemapType = Basemap.Type.STREETS_VECTOR;
double latitude = 20.5937;
double longitude = 78.9629;
int levelOfDetail = 11;
ArcGISMap map = new ArcGISMap(basemapType, latitude, longitude, levelOfDetail);
mapView.setMap(map);

}

/*root.getChildren().add(mapView);

return (scene);
*/
}

private static Scene createScene()
{
System.out.println("Control enters into theScene createScene() ");
Group root = new Group();
Scene scene = new Scene(root, Color.ALICEBLUE);


mapView = new MapView();
setupMobileMap();
root.getChildren().add(mapView);


return (scene);
}

public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{

initAndShowGUI();

//setupMobileMap() ;
System.out.println("Control enters into the main () ");
}
});
}
}

Tags (3)
0 Kudos
0 Replies