List of usage examples for javax.swing JDialog setTitle
public void setTitle(String title)
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
private void editMasterdataRelation(mxCell cell) { EntityFieldMetaDataVO voField = null; RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY); String sSource = ""; String sTarget = ""; EntityMetaDataVO voSourceModify = null; if (cell.getValue() != null && cell.getValue() instanceof EntityFieldMetaDataVO) { voField = (EntityFieldMetaDataVO) cell.getValue(); EntityMetaDataVO voSource = (EntityMetaDataVO) cell.getSource().getValue(); voSourceModify = voSource;// w ww .j a va2 s . co m EntityMetaDataVO voTarget = (EntityMetaDataVO) cell.getTarget().getValue(); sSource = voSource.getEntity(); sTarget = voTarget.getEntity(); EntityMetaDataVO voForeign = MetaDataClientProvider.getInstance().getEntity(voSource.getEntity()); EntityMetaDataVO voEntity = MetaDataClientProvider.getInstance().getEntity(voTarget.getEntity()); panel.setEntity(voEntity); panel.setEntitySource(voForeign); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voForeign.getEntity()).values()); if (voField.getId() != null) { voField = MetaDataClientProvider.getInstance().getEntityField(voForeign.getEntity(), voField.getField()); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo lInfo : LocaleDelegate.getInstance().getAllLocales(false)) { Map<String, String> mp = new HashMap<String, String>(); mp.put(TranslationVO.labelsField[0], LocaleDelegate.getInstance().getResourceByStringId(lInfo, voField.getLocaleResourceIdForLabel())); mp.put(TranslationVO.labelsField[1], LocaleDelegate.getInstance().getResourceByStringId(lInfo, voField.getLocaleResourceIdForDescription())); TranslationVO voTrans = new TranslationVO(lInfo.localeId, lInfo.title, lInfo.language, mp); lstTranslation.add(voTrans); } panel.setTranslation(lstTranslation); panel.setFieldValues(voField); } else { MyGraphModel model = (MyGraphModel) graphComponent.getGraph().getModel(); panel.setFieldValues(voField); panel.setTranslationAndMore(model.getTranslation().get(voField)); } } else if (cell.getValue() != null && cell.getValue() instanceof String) { EntityMetaDataVO voSource = (EntityMetaDataVO) cell.getSource().getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) cell.getTarget().getValue(); sSource = voSource.getEntity(); sTarget = voTarget.getEntity(); EntityMetaDataVO voForeign = MetaDataClientProvider.getInstance().getEntity(voSource.getEntity()); EntityMetaDataVO voEntity = MetaDataClientProvider.getInstance().getEntity(voTarget.getEntity()); voSourceModify = voForeign; panel.setEntity(voEntity); panel.setEntitySource(voForeign); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values()); } double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } }; JDialog dia = new JDialog(mf); dia.setLayout(new TableLayout(cellsDialog)); dia.setTitle("Verbindung von " + sSource + " zu " + sTarget + " bearbeiten"); dia.setLocationRelativeTo(EntityRelationshipModelEditPanel.this); dia.add(panel, "1,1"); dia.setModal(true); panel.setDialog(dia); dia.pack(); dia.setVisible(true); if (panel.getState() == 1) { EntityFieldMetaDataVO vo = panel.getField(); cell.setValue(vo); EntityRelationshipModelEditPanel.this.fireChangeListenEvent(); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(panel.getTranslation().getRows()); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSourceModify, toList); MyGraphModel model = (MyGraphModel) graphComponent.getGraph().getModel(); model.getTranslation().put(vo, panel.getTranslation().getRows()); getGraphComponent().refresh(); loadReferenz(); } else { if (cell.getValue() instanceof String) getGraphModel().remove(cell); } }
From source file:org.nuclos.client.relation.MyGraphModel.java
public JPopupMenu createRelationPopupMenu(final mxCell cell, boolean delete) { final JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.1", "Bezug zu Stammdaten")); i1.addActionListener(new ActionListener() { @Override//w w w . ja va 2 s . com public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OPEN); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); panel.setEntity((EntityMetaDataVO) target.getValue()); panel.setEntitySource((EntityMetaDataVO) source.getValue()); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values()); double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } }; JDialog dia = new JDialog(mf); dia.setLayout(new TableLayout(cellsDialog)); dia.setTitle(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.10", "Bezug zu Stammdaten bearbeiten")); dia.setLocationRelativeTo(editPanel); dia.add(panel, "1,1"); dia.setModal(true); panel.setDialog(dia); dia.pack(); dia.setVisible(true); if (panel.getState() == 1) { EntityFieldMetaDataVO vo = panel.getField(); cell.setValue(vo); mpTransation.put(vo, panel.getTranslation().getRows()); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(panel.getTranslation().getRows()); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } else { remove(cell); } } }); final JMenuItem i2 = new JMenuItem(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.3", "Bezug zu Vorg\u00e4ngen (Unterformularbezug)")); i2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_DIAMOND); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); String sFieldName = null; boolean blnNotSet = true; while (blnNotSet) { sFieldName = JOptionPane.showInputDialog(editPanel, getSpringLocaleDelegate().getMessage( "nuclos.entityrelation.editor.1", "Bitte geben Sie den Namen des Feldes an!")); if (sFieldName == null || sFieldName.length() < 1) { MyGraphModel.this.remove(cell); return; } else if (sFieldName != null) { blnNotSet = false; } } EntityFieldMetaDataVO vo = new EntityFieldMetaDataVO(); vo.setModifiable(true); vo.setLogBookTracking(false); vo.setReadonly(false); vo.setShowMnemonic(true); vo.setInsertable(true); vo.setSearchable(true); vo.setNullable(false); vo.setUnique(true); vo.setDataType("java.lang.String"); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo voLocale : LocaleDelegate.getInstance().getAllLocales(false)) { String sLocaleLabel = voLocale.language; Integer iLocaleID = voLocale.localeId; String sCountry = voLocale.title; Map<String, String> map = new HashMap<String, String>(); TranslationVO translation = new TranslationVO(iLocaleID, sCountry, sLocaleLabel, map); for (String sLabel : labels) { translation.getLabels().put(sLabel, sFieldName); } lstTranslation.add(translation); } vo.setForeignEntity(voTarget.getEntity()); vo.setField(sFieldName); vo.setDbColumn("INTID_" + sFieldName); cell.setValue(vo); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(lstTranslation); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } }); final JMenuItem i4 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.5", "Arbeitsschritt")); i4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OVAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonPermissionException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonFatalException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonBusinessException e1) { LOG.warn("actionPerformed: " + e1); } } }); JMenuItem i5 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.12", "Verbindung l\u00f6sen")); i5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); model.remove(cell); } }); pop.add(i1); pop.add(i2); //pop.add(i3); pop.add(i4); if (delete) { pop.addSeparator(); pop.add(i5); } return pop; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Creates a modal JDialog containing the specified JComponent * for the specified parent./*from ww w . j a v a2 s . co m*/ * The newly created dialog is then centered on the screen and made visible. * * @param parent The parent component. * @param title The title of the dialog. * @param c The component to display. * @see #centerAndShow(Component) */ public static void makeForDialog(Component parent, String title, JComponent c) { if (c == null) return; JDialog dialog = null; if (parent instanceof Frame) dialog = new JDialog((Frame) parent); else if (parent instanceof Dialog) dialog = new JDialog((Dialog) parent); else if (dialog == null) dialog = new JDialog(); //no parent dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.setTitle(title); dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); Container container = dialog.getContentPane(); container.setLayout(new BorderLayout(0, 0)); container.add(c, BorderLayout.CENTER); centerAndShow(dialog); }
From source file:pl.otros.vfs.browser.demo.TestBrowser.java
public static void main(final String[] args) throws InterruptedException, InvocationTargetException, SecurityException, IOException { if (args.length > 1) throw new IllegalArgumentException( "SYNTAX: java... " + TestBrowser.class.getName() + " [initialPath]"); SwingUtilities.invokeAndWait(new Runnable() { @Override/*w w w .j a va 2 s . com*/ public void run() { tryLoadSubstanceLookAndFeel(); final JFrame f = new JFrame("OtrosVfsBrowser demo"); Container contentPane = f.getContentPane(); contentPane.setLayout(new BorderLayout()); DataConfiguration dc = null; final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); File favoritesFile = new File("favorites.properties"); propertiesConfiguration.setFile(favoritesFile); if (favoritesFile.exists()) { try { propertiesConfiguration.load(); } catch (ConfigurationException e) { e.printStackTrace(); } } dc = new DataConfiguration(propertiesConfiguration); propertiesConfiguration.setAutoSave(true); final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null); comp.setSelectionMode(SelectionMode.FILES_ONLY); comp.setMultiSelectionEnabled(true); comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) { @Override public void actionPerformed(ActionEvent e) { FileObject[] selectedFiles = comp.getSelectedFiles(); System.out.println("Selected files count=" + selectedFiles.length); for (FileObject selectedFile : selectedFiles) { try { FileSize fileSize = new FileSize(selectedFile.getContent().getSize()); System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString()); byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l); JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes))); JDialog d = new JDialog(f); d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI()); d.getContentPane().add(sp); d.setSize(600, 400); d.setVisible(true); } catch (Exception e1) { LOGGER.error("Failed to read file", e1); JOptionPane.showMessageDialog(f, (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }); comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) { @Override public void actionPerformed(ActionEvent e) { f.dispose(); try { propertiesConfiguration.save(); } catch (ConfigurationException e1) { e1.printStackTrace(); } System.exit(0); } }); contentPane.add(comp); f.pack(); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); }
From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java
public ReturnValue showOpenDialog(Component parent, String title) { JDialog dialog = createDialog(parent); dialog.setTitle(title); if (size == null) { dialog.pack();//w ww .ja v a 2 s . c om } else { dialog.setSize(size); } dialog.setVisible(true); size = dialog.getSize(); return returnValue; }
From source file:Widgets.Simulation.java
public Simulation(final JFrame aFrame, NetworkElement item) { super(aFrame); grn = ((DynamicalModelElement) item).getGeneNetwork(); plot = new Plot2DPanel(); //closing listener this.addWindowListener(new WindowAdapter() { @Override//from w w w . j a va 2 s . c om public void windowClosing(WindowEvent windowEvent) { if (simulation != null && simulation.myThread_.isAlive()) { simulation.stop(); System.out.print("Simulation is canceled.\n"); JOptionPane.showMessageDialog(new Frame(), "Simulation is canceled.", "Warning!", JOptionPane.INFORMATION_MESSAGE); } escapeAction(); } }); // Model model_.setModel(new DefaultComboBoxModel(new String[] { "Deterministic Model (ODEs)", "Stochastic Model (SDEs)", "Stochastic Simulation (Gillespie Algorithm)" })); model_.setSelectedIndex(0); setModelAction(); //set plot part //display result if (grn.getTimeScale().size() >= 1) { //update parameters numTimeSeries_.setValue(grn.getTraj_itsValue()); tmax_.setValue(grn.getTraj_maxTime()); sdeDiffusionCoeff_.setValue(grn.getTraj_noise()); if (grn.getTraj_model().equals("ode")) model_.setSelectedIndex(0); else if (grn.getTraj_model().equals("sde")) model_.setSelectedIndex(1); else model_.setSelectedIndex(2); //update plot trajPlot.removeAll(); trajPlot.add(trajectoryTabb()); trajPlot.updateUI(); trajPlot.setVisible(true); trajPlot.repaint(); analyzeResult.setVisible(true); } /** * ACTIONS */ model_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setModelAction(); } }); analyzeResult.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { final JDialog a = new JDialog(); a.setSize(new Dimension(500, 450)); a.setModal(true); a.setTitle("Gene List (seperated by ';')"); a.setLocationRelativeTo(null); final JTextArea focusGenesArea = new JTextArea(); focusGenesArea.setLineWrap(true); focusGenesArea.setEditable(false); focusGenesArea.setRows(3); String geneNames = ""; for (int i = 0; i < grn.getNodes().size(); i++) geneNames += grn.getNodes().get(i).getLabel() + ";"; focusGenesArea.setText(geneNames); JButton submitButton = new JButton("Submit"); JButton cancelButton = new JButton("Cancel"); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(submitButton); buttonPanel.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { a.dispose(); } }); submitButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { a.dispose(); final JDialog a = new JDialog(); a.setSize(new Dimension(500, 450)); a.setModal(true); a.setTitle("Statistics"); a.setLocationRelativeTo(null); if (grn.getTimeSeries().isEmpty()) { JOptionPane.showMessageDialog(new Frame(), "Please run the simulation first.", "Warning!", JOptionPane.INFORMATION_MESSAGE); } else { JPanel infoPanel = new JPanel(); infoPanel.setLayout(new BorderLayout()); //output String[] focusGenes = focusGenesArea.getText().split(";"); ; String content = ""; //discrete the final state int dimension = grn.getNodes().size(); //get gene index int[] focus_index = new int[focusGenes.length]; for (int j = 0; j < focusGenes.length; j++) for (int i = 0; i < dimension; i++) if (grn.getNode(i).getLabel().equals(focusGenes[j])) focus_index[j] = i; JScrollPane jsp = new JScrollPane(); //calculate steady states grn.setLand_itsValue((Integer) numTimeSeries_.getModel().getValue()); int[] isConverge = new int[grn.getTraj_itsValue()]; String out = calculateSteadyStates(focusGenes, focus_index, isConverge); //show the convergence final JDialog ifconvergent = new JDialog(); ifconvergent.setSize(new Dimension(500, 450)); ifconvergent.setModal(true); ifconvergent.setTitle("Convergence"); ifconvergent.setLocationRelativeTo(null); ConvergenceTable tablePanel = new ConvergenceTable(isConverge); JButton continueButton = new JButton("Click to check the attractors."); continueButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { ifconvergent.dispose(); } }); JPanel ifconvergentPanel = new JPanel(); ifconvergentPanel.setLayout(new BorderLayout()); ifconvergentPanel.add(tablePanel, BorderLayout.NORTH); ifconvergentPanel.add(continueButton, BorderLayout.SOUTH); ifconvergent.add(ifconvergentPanel); ifconvergent.setVisible(true); //show attractors if (out.equals("ok")) { AttractorTable panel = new AttractorTable(grn, focusGenes); jsp.setViewportView(panel); } else if (grn.getSumPara().size() == 0) content += "Cannot find a steady state!"; else content += "\nI dont know why!"; if (content != "") { JLabel warningLabel = new JLabel(); warningLabel.setText(content); jsp.setViewportView(warningLabel); } grn.setSumPara(null); grn.setCounts(null); //jsp.setPreferredSize(new Dimension(280,130)); jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); infoPanel.add(jsp, BorderLayout.CENTER); a.add(infoPanel); a.setVisible(true); } //end of else } }); JPanel options3 = new JPanel(); options3.setLayout(new BorderLayout()); options3.add(focusGenesArea, BorderLayout.NORTH); options3.add(buttonPanel); options3.setBorder(new EmptyBorder(5, 0, 5, 0)); a.add(options3); a.setVisible(true); } }); runButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { //System.out.print("Memory start: "+s_runtime.totalMemory()+"\n"); enterAction(); } }); cancelButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { if (simulation != null) simulation.stop(); System.out.print("Simulation is canceled!\n"); } }); fixButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { JDialog a = new JDialog(); a.setTitle("Fixed initial values"); a.setSize(new Dimension(400, 400)); a.setLocationRelativeTo(null); JPanel speciesPanel = new JPanel(); String[] columnName = { "Name", "InitialValue" }; boolean editable = false; //false; new SpeciesTable(speciesPanel, columnName, grn, editable); /** LAYOUT **/ JPanel wholePanel = new JPanel(); wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS)); wholePanel.add(speciesPanel); a.add(wholePanel); a.setModal(true); a.setVisible(true); } }); randomButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { final JDialog a = new JDialog(); a.setTitle("Set boundaries"); a.setSize(new Dimension(300, 200)); a.setModal(true); a.setLocationRelativeTo(null); JPanel upPanel = new JPanel(); JLabel upLabel = new JLabel("Input the upper boundary: "); final JTextField upValue = new JTextField("3"); upPanel.setLayout(new BoxLayout(upPanel, BoxLayout.X_AXIS)); upPanel.add(upLabel); upPanel.add(upValue); JPanel lowPanel = new JPanel(); JLabel lowLabel = new JLabel("Input the lower boundary: "); final JTextField lowValue = new JTextField("0"); lowPanel.setLayout(new BoxLayout(lowPanel, BoxLayout.X_AXIS)); lowPanel.add(lowLabel); lowPanel.add(lowValue); JPanel buttonPanel = new JPanel(); JButton submit = new JButton("Submit"); JButton cancel = new JButton("Cancel"); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(submit); buttonPanel.add(cancel); buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); submit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (upValue.getText().equals("")) JOptionPane.showMessageDialog(null, "Please input upper boundary", "Error", JOptionPane.ERROR_MESSAGE); else { try { upbound = Double.parseDouble(upValue.getText()); if (lowValue.getText().equals("")) JOptionPane.showMessageDialog(null, "Please input lower boundary", "Error", JOptionPane.ERROR_MESSAGE); else { try { lowbound = Double.parseDouble(lowValue.getText()); if (upbound < lowbound) JOptionPane.showMessageDialog(null, "Upper boundary should be not less than lower boundary", "Error", JOptionPane.ERROR_MESSAGE); else a.dispose(); } catch (Exception er) { JOptionPane.showMessageDialog(null, "Invalid value", "Error", JOptionPane.INFORMATION_MESSAGE); MsgManager.Messages.errorMessage(er, "Error", ""); } } } catch (Exception er) { JOptionPane.showMessageDialog(null, "Invalid value", "Error", JOptionPane.INFORMATION_MESSAGE); MsgManager.Messages.errorMessage(er, "Error", ""); } } } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "The default values are used!", "", JOptionPane.INFORMATION_MESSAGE); a.dispose(); } }); JPanel wholePanel = new JPanel(); wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS)); wholePanel.add(upPanel); wholePanel.add(lowPanel); wholePanel.add(buttonPanel); wholePanel.setBorder(new EmptyBorder(5, 5, 5, 5)); a.add(wholePanel); a.setVisible(true); } }); }