List of usage examples for java.awt Frame getComponents
public Component[] getComponents()
From source file:net.bioclipse.model.ScatterPlotMouseHandler.java
private ChartPanel getChartPanel(MouseEvent me) { Point2D p = null;/* w w w .j av a 2 s . c om*/ Frame sourceFrame; ChartPanel selectedPanel = null; if (me.getSource() instanceof Frame) { sourceFrame = (Frame) me.getSource(); Component[] components = sourceFrame.getComponents(); boolean foundChartPanel = false; for (Component component : components) { if (component instanceof ChartPanel) { selectedPanel = (ChartPanel) component; // selectedChart = chartPanel.getChart(); foundChartPanel = true; break; } } assert foundChartPanel : "The source Frame of the event does not contain a ChartPanel"; } else if (me.getSource() instanceof ChartPanel) { selectedPanel = (ChartPanel) me.getSource(); } else { //Can't throw checked exception because the methods that use getChart doesn't throw Exception in their signatures throw new RuntimeException("The source of any mouse event on ScatterPlotMouseHandler should" + " be either Frame or ChartPanel"); } return selectedPanel; }