/** Used to find the global attributes that another inspector has set so I can share it. */ ChartGenerator chartToUse(final String sName, Frame parent, final GUIState simulation) { Bag charts = new Bag(); if (simulation.guiObjects != null) for (int i = 0; i < simulation.guiObjects.numObjs; i++) if (simulation.guiObjects.objs[i] instanceof ChartGenerator && validChartGenerator((ChartGenerator) (simulation.guiObjects.objs[i]))) charts.add(simulation.guiObjects.objs[i]); if (charts.numObjs == 0) return createNewChart(simulation); // init the dialog panel JPanel p = new JPanel(); p.setLayout(new BorderLayout()); String[] chartNames = new String[charts.numObjs + 1]; chartNames[0] = "[Create a New Chart]"; for (int i = 0; i < charts.numObjs; i++) chartNames[i + 1] = ((ChartGenerator) (charts.objs[i])).getTitle(); // add widgets JPanel panel2 = new JPanel(); panel2.setLayout(new BorderLayout()); panel2.setBorder(new javax.swing.border.TitledBorder("Plot on Chart...")); JComboBox encoding = new JComboBox(chartNames); panel2.add(encoding, BorderLayout.CENTER); p.add(panel2, BorderLayout.SOUTH); // ask if (JOptionPane.showConfirmDialog( parent, p, "Create a New Chart...", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) return null; if (encoding.getSelectedIndex() == 0) return createNewChart(simulation); else return (ChartGenerator) (charts.objs[encoding.getSelectedIndex() - 1]); }