List of usage examples for javax.swing JScrollPane setViewportView
public void setViewportView(Component view)
From source file:pcgen.gui2.dialog.AboutDialog.java
/** * Construct the awards panel. This panel shows each award * the pcgen project has been awarded/*from w ww.jav a2s . c o m*/ * * @return The awards panel. */ private JPanel buildAwardsPanel() { JScrollPane sp = new JScrollPane(); JPanel panel = new JPanel(); JPanel aPanel = new JPanel(); aPanel.setLayout(new GridBoxLayout(2, 2)); aPanel.setBackground(Color.WHITE); Icon goldIcon = Icons.createImageIcon("gold200x200-2005.gif"); if (goldIcon != null) { JLabel e2005 = new JLabel(goldIcon); aPanel.add(e2005); JTextArea title = new JTextArea(); title.setLineWrap(true); title.setWrapStyleWord(true); title.setEditable(false); title.setText(LanguageBundle.getString("in_abt_awards_2005_ennie")); aPanel.add(title); } Icon bronzeIcon = Icons.createImageIcon("bronze200x200-2003.gif"); if (bronzeIcon != null) { JLabel e2003 = new JLabel(bronzeIcon); aPanel.add(e2003); JTextArea title = new JTextArea(); title.setLineWrap(true); title.setWrapStyleWord(true); title.setEditable(false); title.setText(LanguageBundle.getString("in_abt_awards_2003_ennie")); aPanel.add(title); } sp.setViewportView(aPanel); panel.add(sp, BorderLayout.CENTER); return panel; }
From source file:pcgen.gui2.dialog.AboutDialog.java
/** * Construct the license panel. This panel shows the full * text of the license under which PCGen is distributed. * * @return The license panel./*w w w. ja va 2 s . c o m*/ */ private JPanel buildLicensePanel() { JPanel lPanel = new JPanel(); JScrollPane license = new JScrollPane(); JTextArea lgplArea = new JTextArea(); lPanel.setLayout(new BorderLayout()); lgplArea.setEditable(false); InputStream lgpl = ClassLoader.getSystemResourceAsStream("LICENSE"); //$NON-NLS-1$ if (lgpl != null) { try { lgplArea.read(new InputStreamReader(lgpl), "LICENSE"); //$NON-NLS-1$ } catch (IOException ioe) { lgplArea.setText(LanguageBundle.getString("in_abt_license_read_err1")); //$NON-NLS-1$ } } else { lgplArea.setText(LanguageBundle.getString("in_abt_license_read_err2")); //$NON-NLS-1$ } license.setViewportView(lgplArea); lPanel.add(license, BorderLayout.CENTER); return lPanel; }
From source file:savant.util.swing.TrackChooser.java
private void initLayout() { this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); //FILLER//ww w. ja v a2s .c o m //LEFT LABEL JLabel leftLabel = new JLabel("All Tracks"); leftLabel.setFont(new Font(null, Font.BOLD, 12)); c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 5, 5, 5); add(leftLabel, c); // RIGHT LABEL JLabel rightLabel = new JLabel("Selected Tracks"); rightLabel.setFont(new Font(null, Font.BOLD, 12)); c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; add(rightLabel, c); //LEFT LIST leftList = new JList(); JScrollPane leftScroll = new JScrollPane(); leftScroll.setViewportView(leftList); leftScroll.setMinimumSize(new Dimension(450, 300)); leftScroll.setPreferredSize(new Dimension(450, 300)); c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 4; add(leftScroll, c); //RIGHT LIST rightList = new JList(); JScrollPane rightScroll = new JScrollPane(); rightScroll.setViewportView(rightList); rightScroll.setMinimumSize(new Dimension(450, 300)); rightScroll.setPreferredSize(new Dimension(450, 300)); c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; this.add(rightScroll, c); // MOVE RIGHT c.weightx = 0.0; c.weighty = 0.5; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; add(createMoveRight(), c); // MOVE LEFT c.gridy = 2; add(createMoveLeft(), c); // ALL RIGHT c.gridy = 3; add(createAllRight(), c); //ALL LEFT c.gridy = 4; this.add(createAllLeft(), c); //FILTER c.gridx = 0; c.gridy = 5; add(createFilterPanel(), c); //AUTO SELECT ALL c.gridx = 2; add(createSelectAllCheck(), c); //SEPARATOR JSeparator separator1 = new JSeparator(SwingConstants.HORIZONTAL); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.weightx = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; add(separator1, c); if (selectBase) { //SELECT BASE PANEL JPanel selectBasePanel = new JPanel(new BorderLayout()); c.gridwidth = 2; add(selectBasePanel, c); //SELECT BASE LABEL JLabel selectBaseLabel = new JLabel("(Optional) Select Base: "); selectBasePanel.add(selectBaseLabel, BorderLayout.WEST); //SELECT BASE FIELD selectBaseField = new JTextField(); selectBasePanel.add(selectBaseField, BorderLayout.CENTER); //SELECT BASE EXAMPLE JLabel selectBaseExample = new JLabel(" ex. 123,456,789"); selectBasePanel.add(selectBaseExample, BorderLayout.EAST); //SEPARATOR JSeparator separator2 = new JSeparator(SwingConstants.HORIZONTAL); c.gridwidth = GridBagConstraints.REMAINDER; add(separator2, c); } JPanel okCancelPanel = new JPanel(new BorderLayout()); c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; c.fill = GridBagConstraints.NONE; add(okCancelPanel, c); //OK okCancelPanel.add(createOKButton(), BorderLayout.CENTER); //CANCEL okCancelPanel.add(createCancelButton(), BorderLayout.EAST); pack(); }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getDetailsPanel() { if (detailsPanel == null) { detailsPanel = new JPanel(new GridLayout(5, 1)); JScrollPane aux = new JScrollPane(); aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Description"))); aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); aux.setViewportView(getDescriptionPanel()); detailsPanel.add(aux);// w w w .ja v a 2 s .com aux = new JScrollPane(); aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Purpose"))); aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); aux.setViewportView(getPurposePanel()); detailsPanel.add(aux); aux = new JScrollPane(); aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Use"))); aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); aux.setViewportView(getUsePanel()); detailsPanel.add(aux); aux = new JScrollPane(); aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("Misuse"))); aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); aux.setViewportView(getMisusePanel()); detailsPanel.add(aux); aux = new JScrollPane(); aux.setBorder(BorderFactory.createTitledBorder(GDLEditorLanguageManager.getMessage("References"))); aux.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); aux.setViewportView(getReferencePanel()); detailsPanel.add(aux); } return detailsPanel; }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.QueryComponentExpressionPanel.java
/** * Creates the excluded terms panel./*from ww w .j a v a 2 s . co m*/ */ private synchronized void createExcludedTermsPanel() { // create table for displaying excluded constraints excludedConstraintTableModel = new TerminologyConstraintTableModel(); excludedConstraintsTable = new JTable(excludedConstraintTableModel); excludedConstraintsTable.setDefaultRenderer(TerminologyConstraint.class, new TerminologyConstraintTableCellRenderer(humanReadableRender)); excludedConstraintsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // get row a click int row = excludedConstraintsTable.rowAtPoint(e.getPoint()); if (row > -1 && e.getClickCount() == 2) { // addingNew = false; editingExisting = true; // get constraint at row activeTerminologyConstraint = excludedConstraintTableModel.getConstraintAtRow(row); // set constraint in activeConstraintPanel and display activeConstraintsDialog activeConstraintPanel.setConstraint(activeTerminologyConstraint); activeConstraintsDialog.setVisible(true); } } }); // create a label and control buttons for editing excluded constraints JPanel p3 = new JPanel(); p3.setLayout(new BoxLayout(p3, BoxLayout.LINE_AXIS)); p3.add(new JLabel("Edit excluded constraints")); p3.add(Box.createHorizontalGlue()); // add panel for editing excluded terms JideButton addExclusionTermButton = new JideButton(new AbstractAction("", addExclusionIcon) { public void actionPerformed(ActionEvent e) { // show activeConstraintsDialog // addingNew = true; activeConstraintsDialog.setVisible(true); } }); addExclusionTermButton.setName("addExclusionTermButton"); JideButton deleteExclusionTermButton = new JideButton(new AbstractAction("", deleteExclusionIcon) { public void actionPerformed(ActionEvent e) { final int row = excludedConstraintsTable.getSelectedRow(); if (row > -1) { QueryStatement oldValue = queryService.getActiveQuery(); // get term at row TerminologyConstraint term = (TerminologyConstraint) excludedConstraintTableModel .getValueAt(row, 1); // remove term from sub query componentExpression.removeExcludedConstraint(term); Runnable runnable = new Runnable() { public void run() { excludedConstraintTableModel.deleteRow(row); } }; SwingUtilities.invokeLater(runnable); // notify listeners propertyChangeTrackerService.firePropertyChanged(ACTIVE_QUERY_CHANGED, oldValue, queryService.getActiveQuery(), QueryComponentExpressionPanel.this); } } }); deleteExclusionTermButton.setName("deleteExclusionTermButton"); // add buttons to p3 p3.add(addExclusionTermButton); p3.add(deleteExclusionTermButton); // create panel that contains excluded constraints excludedConstraintsPanel = new JPanel(new BorderLayout()); excludedConstraintsPanel.setBorder(BorderFactory.createTitledBorder("Excluded constraints")); excludedConstraintsPanel.add(p3, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(excludedConstraintsTable); excludedConstraintsPanel.add(scrollPane, BorderLayout.CENTER); }
From source file:updater.UpdaterGUI.java
@SuppressWarnings("resource") public UpdaterGUI() { try {/* w w w . j a v a 2s .c o m*/ URL url1 = new URL( "https://raw.githubusercontent.com/kvsjxd/Droid-PC-Suite/master/.release-version.txt"); ReadableByteChannel obj1 = Channels.newChannel(url1.openStream()); FileOutputStream outputstream1 = new FileOutputStream(".release-version.txt"); outputstream1.getChannel().transferFrom(obj1, 0, Long.MAX_VALUE); URL url2 = new URL( "https://raw.githubusercontent.com/kvsjxd/Droid-PC-Suite/master/.release-changelog.txt"); ReadableByteChannel obj2 = Channels.newChannel(url2.openStream()); FileOutputStream outputstream2 = new FileOutputStream(".release-changelog.txt"); outputstream2.getChannel().transferFrom(obj2, 0, Long.MAX_VALUE); FileReader file = new FileReader(".release-version.txt"); BufferedReader reader = new BufferedReader(file); String DownloadedString = reader.readLine(); File file2 = new File(".release-version.txt"); if (file2.exists() && !file2.isDirectory()) { file2.delete(); } AvailableUpdate = Double.parseDouble(DownloadedString); InputStreamReader reader2 = new InputStreamReader( getClass().getResourceAsStream("/others/app-version.txt")); String tmp = IOUtils.toString(reader2); ApplicationVersion = Double.parseDouble(tmp); } catch (Exception e) { e.printStackTrace(); } setIconImage(Toolkit.getDefaultToolkit().getImage(UpdaterGUI.class.getResource("/graphics/Icon.png"))); setResizable(false); setType(Type.UTILITY); setTitle("Updater"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 430, 415); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblApplicationVersion = new JLabel("App Version: v" + ApplicationVersion); lblApplicationVersion.setBounds(12, 12, 222, 15); contentPane.add(lblApplicationVersion); JLabel lblUpdateVersion = new JLabel("Update Version: v" + AvailableUpdate); lblUpdateVersion.setBounds(12, 30, 222, 15); contentPane.add(lblUpdateVersion); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(0, 51, 422, 281); contentPane.add(scrollPane); JTextArea UpdateChangelogViewer = new JTextArea(); scrollPane.setViewportView(UpdateChangelogViewer); JButton btnDownload = new JButton("Download"); btnDownload.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFrame parentFrame = new JFrame(); JFileChooser fileChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Zip Files", "zip"); fileChooser.setFileFilter(filter); fileChooser.setDialogTitle("Save as"); int userSelection = fileChooser.showSaveDialog(parentFrame); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = fileChooser.getSelectedFile(); try { URL url = new URL("https://github.com/kvsjxd/Droid-PC-Suite/releases/download/" + AvailableUpdate + "/DPCS.v" + AvailableUpdate + ".Stable.zip"); ReadableByteChannel obj = Channels.newChannel(url.openStream()); FileOutputStream outputstream = new FileOutputStream(fileToSave.getAbsolutePath() + ".zip"); outputstream.getChannel().transferFrom(obj, 0, Long.MAX_VALUE); JOptionPane.showMessageDialog(null, "Download complete!\nPlease delete this version and extract the downloaded zip\nwhich is saved at " + fileToSave.getAbsolutePath() + ".zip"); } catch (Exception e) { e.printStackTrace(); } } } }); btnDownload.setBounds(140, 344, 117, 25); contentPane.add(btnDownload); try { FileReader reader3 = new FileReader(new File(".release-changelog.txt")); UpdateChangelogViewer.read(reader3, ""); File file3 = new File(".release-changelog.txt"); if (file3.exists() && !file3.isDirectory()) { file3.delete(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:utybo.branchingstorytree.swing.editor.StoryNodesEditor.java
public StoryNodesEditor() { setLayout(new MigLayout("", "[:33%:300px][grow 150]", "[grow][]")); JScrollPane scrollPane = new JScrollPane(); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollPane, "cell 0 0,grow"); jlist = new JList<>(); jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jlist.setCellRenderer(new SubstanceDefaultListCellRenderer() { @Override/*w ww. jav a2 s .c om*/ public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, o, index, isSelected, cellHasFocus); if (o instanceof StorySingleNodeEditor) { if (((StorySingleNodeEditor) o).getStatus() == Status.ERROR) label.setForeground(Color.RED.darker()); if (o instanceof StoryLogicalNodeEditor) label.setIcon(new ImageIcon(Icons.getImage("LogicalNode", 16))); else if (o instanceof StoryTextNodeEditor) label.setIcon(new ImageIcon(Icons.getImage("TextNode", 16))); else if (o instanceof StoryVirtualNodeEditor) label.setIcon(new ImageIcon(Icons.getImage("VirtualNode", 16))); } return label; } }); jlist.addListSelectionListener(e -> { if (jlist.getSelectedValue() instanceof JComponent) { container.removeAll(); container.add(jlist.getSelectedValue()); container.revalidate(); container.repaint(); } }); JScrollablePanel pan = new JScrollablePanel(new BorderLayout(0, 0)); jlist.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { scrollPane.revalidate(); pan.revalidate(); jlist.revalidate(); revalidate(); repaint(); } }); pan.setScrollableWidth(ScrollableSizeHint.FIT); pan.setScrollableHeight(ScrollableSizeHint.STRETCH); pan.add(jlist, BorderLayout.CENTER); scrollPane.setViewportView(pan); container = new JPanel(); add(container, "cell 1 0,grow"); container.setLayout(new BorderLayout(0, 0)); container.add(new JPanel(), BorderLayout.CENTER); // TODO JPanel panel = new JPanel(); add(panel, "cell 0 1 2 1,alignx leading,growy"); JButton btnAddNode = new JButton(Lang.get("editor.panel.add"), new ImageIcon(Icons.getImage("Add Subnode", 16))); btnAddNode.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { createMenu().show(btnAddNode, e.getX(), e.getY()); } }); panel.add(btnAddNode); JButton btnRemoveNode = new JButton(Lang.get("editor.panel.remove"), new ImageIcon(Icons.getImage("Delete Subnode", 16))); btnRemoveNode.addActionListener(e -> removeNode()); panel.add(btnRemoveNode); }
From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java
@SuppressWarnings("unchecked") public AboutDialog(OpenBSTGUI parent) { super(parent); setTitle(Lang.get("about.title")); setModalityType(ModalityType.APPLICATION_MODAL); JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER)); banner.setBackground(OpenBSTGUI.OPENBST_BLUE); JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48))); lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); banner.add(lblOpenbst, "flowx,cell 0 0,alignx center"); getContentPane().add(banner, BorderLayout.NORTH); JPanel pan = new JPanel(); pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]")); getContentPane().add(pan, BorderLayout.CENTER); JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/"); Font f = lblWebsite.getFont(); @SuppressWarnings("rawtypes") Map attrs = f.getAttributes(); attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); lblWebsite.setFont(f.deriveFont(attrs)); lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE); lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lblWebsite.addMouseListener(new MouseAdapter() { @Override/*from w w w . j ava 2 s . com*/ public void mouseClicked(MouseEvent e) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI()); } catch (IOException | URISyntaxException e1) { OpenBST.LOG.warn("Exception when trying to open website", e1); } } } }); pan.add(lblWebsite, "cell 0 0,alignx center"); JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION)); pan.add(lblVersion, "flowy,cell 0 1"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false)); pan.add(scrollPane, "cell 0 2,grow"); JTextArea textArea = new JTextArea(); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11))); try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) { textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8)); } catch (IOException ex) { OpenBST.LOG.warn("Loading about information failed", ex); } textArea.setEditable(false); textArea.setCaretPosition(0); scrollPane.setViewportView(textArea); JLabel lblTranslatedBy = new JLabel(Lang.get("author")); pan.add(lblTranslatedBy, "cell 0 1"); setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400)); setLocationRelativeTo(parent); }
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/* ww w . j ava 2 s. c o m*/ 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); } }); }
From source file:zxmax.tools.timerreview.gui.StartTimerWindow.java
private Component getPnlNewTimer() { setTitle(I18N.getLabel(getClass(), "window.title")); JPanel pnlNewTimer = new JPanel(); LayoutManager layout = new MigLayout("flowy", "[328.00][grow,fill]", "[][][][][]"); taFocusOn = new JTextArea(); taFocusOn.setWrapStyleWord(true);//from w w w . j a va2s .co m JScrollPane spFocusOn = new JScrollPane(); tfTitle = new JTextField(30); JButton btnStart = new JButton(); pnlNewTimer.setLayout(layout); btnStart.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_BTN_START_LABEL)); taFocusOn.setColumns(20); taFocusOn.setForeground(new Color(0, 153, 0)); taFocusOn.setRows(5); taFocusOn.setTabSize(2); taFocusOn.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TEXT)); taFocusOn.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TOOL_TIP)); spFocusOn.setViewportView(taFocusOn); taFocusOn.getAccessibleContext().setAccessibleName("taFocusOn"); btnStart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { storeDataAndStartTimer(); } }); btnStart.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { logger.debug(evt.getKeyCode() + ", " + evt.getKeyChar()); if (KeyEvent.VK_ENTER == evt.getKeyCode()) { storeDataAndStartTimer(); } } }); JLabel lblTitle = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_TITLE_LABEL)); pnlNewTimer.add(lblTitle, "cell 0 0"); pnlNewTimer.add(tfTitle, "cell 0 1 2 1,growx"); JLabel lblFocusOn = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_LABEL)); pnlNewTimer.add(lblFocusOn, "cell 0 2"); pnlNewTimer.add(spFocusOn, "cell 0 3 2 1,growx"); pnlNewTimer.add(btnStart, "cell 0 4 2 1,growx"); Box horizontalBox = Box.createHorizontalBox(); pnlNewTimer.add(horizontalBox, "flowx,cell 1 0"); JLabel lblDurata = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_LABEL)); lblDurata.setHorizontalAlignment(SwingConstants.RIGHT); pnlNewTimer.add(lblDurata, "cell 1 0,alignx right"); lblDurata.setLabelFor(txtDurata); txtDurata = new JTextField("20"); txtDurata.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_TOOL_TIP)); pnlNewTimer.add(txtDurata, "cell 1 0,alignx center"); txtDurata.setColumns(2); return pnlNewTimer; }