private void captureWindow(View _aView, String _aWindow) { if (_aWindow == null) { return; } RootPaneContainer root; if (_parentFrame != null) { root = _parentFrame; } else { root = this; } Component comp = _aView.getComponent(_aWindow); if (comp == null) { return; } // Dimension size = comp.getSize(); if (comp instanceof DrawingFrame) { comp.setVisible(true); Container contentPane = ((RootPaneContainer) comp).getContentPane(); contentPane.setVisible(true); root.setContentPane(contentPane); Component glassPane = ((RootPaneContainer) comp).getGlassPane(); root.setGlassPane(glassPane); glassPane.setVisible(true); ((DrawingFrame) comp).setKeepHidden(true); ((DrawingFrame) comp).setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } else if (comp instanceof JDialog) { comp.setVisible(true); Container contentPane = ((RootPaneContainer) comp).getContentPane(); contentPane.setVisible(true); root.setContentPane(contentPane); Component glassPane = ((RootPaneContainer) comp).getGlassPane(); root.setGlassPane(glassPane); glassPane.setVisible(true); ((JDialog) comp).dispose(); } else { root.getContentPane().setLayout(new java.awt.BorderLayout()); root.getContentPane().add(comp, java.awt.BorderLayout.CENTER); root.getContentPane().validate(); Container oldParent = comp.getParent(); if (oldParent != null) { oldParent.validate(); } } if (_parentFrame != null) { _parentFrame.pack(); } }
/** * Constructor EjsSimulationControl * * @param model * @param frame * @param args */ public EjsSimulationControl(Simulation model, DrawingFrame frame, String[] args) { super( model, "name=controlFrame;title=OSP Simulation;location=400,0;layout=border;exit=true; visible=false"); //$NON-NLS-1$ this.model = model; addTarget("control", this); // $NON-NLS-1$ addTarget("model", model); // $NON-NLS-1$ if (frame != null) { getMainFrame().setAnimated(frame.isAnimated()); getMainFrame().setAutoclear(frame.isAutoclear()); getMainFrame().setBackground(frame.getBackground()); getMainFrame().setTitle(frame.getTitle()); drawingPanel = frame.getDrawingPanel(); addObject( drawingPanel, "Panel", "name=drawingPanel; parent=controlFrame; position=center"); //$NON-NLS-1$ //$NON-NLS-2$ frame.setDrawingPanel(null); frame.dispose(); } add( "Panel", "name=controlPanel; parent=controlFrame; layout=border; position=south"); //$NON-NLS-1$ // //$NON-NLS-2$ add( "Panel", "name=buttonPanel;position=west;parent=controlPanel;layout=flow"); //$NON-NLS-1$ // //$NON-NLS-2$ // add("Button", "parent=buttonPanel; text=Start; // action=control.runSimulation();name=runButton"); // add("Button", "parent=buttonPanel; text=Step; action=control.stepAnimation()"); // add("Button", "parent=buttonPanel; text=Reset; action=control.resetAnimation()"); add( "Button", "parent=buttonPanel;tooltip=Start and stop simulation;image=/org/opensourcephysics/resources/controls/images/play.gif; action=control.runSimulation();name=runButton"); //$NON-NLS-1$ //$NON-NLS-2$ add( "Button", "parent=buttonPanel;tooltip=Step simulation;image=/org/opensourcephysics/resources/controls/images/step.gif; action=control.stepSimulation();name=stepButton"); //$NON-NLS-1$ //$NON-NLS-2$ add( "Button", "parent=buttonPanel; tooltip=Reset simulation;image=/org/opensourcephysics/resources/controls/images/reset.gif; action=control.resetSimulation();name=resetButton"); //$NON-NLS-1$ //$NON-NLS-2$ controlPanel = ((JPanel) getElement("controlPanel").getComponent()); // $NON-NLS-1$ controlPanel.setBorder(new EtchedBorder()); customize(); model.setControl(this); initialize(); loadXML(args); java.awt.Container cont = (java.awt.Container) getElement("controlFrame").getComponent(); // $NON-NLS-1$ if (!org.opensourcephysics.display.OSPRuntime.appletMode) { cont.setVisible(true); } if (model instanceof PropertyChangeListener) { addPropertyChangeListener((PropertyChangeListener) model); } getMainFrame().pack(); // make sure everything is showing getMainFrame().doLayout(); GUIUtils.showDrawingAndTableFrames(); }