I am making a Java GUI
application, wherein a JPanel displays a HeatMap
using the HeatMap
Java class. When a user right clicks on this JPanel, a popup menu
is displayed. Within this, the first option is to View the zoomed heatmap in a separate window. On clicking this option a new window should open providing a bigger image of the actual HeatMap
. I am using the following code to perform this:
JOptionPane.showMessageDialog(new GUIMain(), getPanel(), "Zoomed heat map", JOptionPane.PLAIN_MESSAGE);
getPanel()
is a method that returns a panel containing the heatmap.
private JPanel getPanel() {
JPanel zoomedImagePanel = new JPanel();
zoomedImagePanel.add(getHeatMap());
zoomedImagePanel.repaint();
zoomedImagePanel.revalidate();
return zoomedImagePanel;
}
With the above code, I get a very small HeatMap
in a new window and the HeatMap
from the main JPanel
disappears completely.
Is using JOptionPane the wrong way to display the zoomed image? Also, not sure why the HeatMap
from the main JPanel
in the parent window disappears.