List of usage examples for javax.swing JScrollPane setHorizontalScrollBarPolicy
@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED", "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER", "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane scrollbar policy") public void setHorizontalScrollBarPolicy(int policy)
From source file:qic.launcher.Main.java
private void startGUI(TakeDown installer) { TextAreaWithBackground textArea = new TextAreaWithBackground(); JButton launchButton = new JButton(" Launch "); launchButton.setEnabled(false);/*from w w w . j ava 2 s . c o m*/ JProgressBar progressBar = new JProgressBar(); launchButton.addActionListener(e -> { runAIC(); System.exit(0); }); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS)); southPanel.add(progressBar); southPanel.add(launchButton); JFrame frame = new JFrame("QIC Search Updater"); frame.setIconImage(new ImageIcon(getClass().getResource("/q.png")).getImage()); frame.setLayout(new BorderLayout(5, 5)); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.getContentPane().add(southPanel, BorderLayout.SOUTH); frame.setSize(495, 445); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); textArea.setText("Loading path notes..."); String imgUrl = "http://poeqic.github.io/launcher/images/background.png"; try { Image image = ImageIO.read(new URL(imgUrl)); if (image != null) textArea.setBackgroundImage(image); } catch (IOException ex) { logger.error("Error while loading background image from: " + imgUrl, ex); } Worker<String> pathNotesWorker = new Worker<String>(() -> URLConnectionReader.getText(CHANGELOG_URL), s -> textArea.setText(s), e -> showErrorAndQuit(e)); pathNotesWorker.execute(); Worker<Boolean> updaterWorker = new Worker<Boolean>(() -> { progressBar.setIndeterminate(true); return installer.installOrUpdate(); }, b -> { progressBar.setIndeterminate(false); launchButton.setEnabled(true); }, e -> showErrorAndQuit(e)); updaterWorker.execute(); }
From source file:savant.view.swing.Frame.java
/** * Construct a new Frame for holding a track. * * @param df the DataFormat, so the frame can do any format-specific * initialisation (e.g. smaller height for sequence tracks) *///from w w w . j ava 2 s . c o m public Frame(DataFormat df) { super(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK)); sequence = df == DataFormat.SEQUENCE; // Component which displays the legend component. legend = new JComponent() { @Override public Dimension getPreferredSize() { for (Track t : tracks) { Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode()); if (d != null) { return d; } } return new Dimension(0, 0); } @Override public Dimension getMinimumSize() { return getPreferredSize(); } @Override public void paintComponent(Graphics g) { for (Track t : tracks) { Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode()); if (d != null) { Graphics2D g2 = (Graphics2D) g; GradientPaint gp = new GradientPaint(0, 0, Color.WHITE, 0, 60, new Color(230, 230, 230)); g2.setPaint(gp); g2.fillRect(0, 0, d.width, d.height); g2.setColor(Color.BLACK); g2.draw(new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); t.getRenderer().drawLegend(g2, t.getDrawingMode()); return; } } } }; legend.setVisible(false); frameLandscape = new JLayeredPane(); //add graphPane -> jlp -> scrollPane jlp = new JLayeredPane(); jlp.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.gridx = 0; gbc.gridy = 0; //scrollpane JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setWheelScrollingEnabled(false); scrollPane.setBorder(null); graphPane = new GraphPane(this); jlp.add(graphPane, gbc, 0); scrollPane.getViewport().add(jlp); //GRID FRAMEWORK AND COMPONENT ADDING... frameLandscape.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; //add sidepanel sidePanel = new JPanel() { @Override public Dimension getMinimumSize() { return new Dimension(0, 0); } }; sidePanel.setLayout(new GridBagLayout()); sidePanel.setOpaque(false); sidePanel.setVisible(false); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; c.gridx = 1; c.gridy = 0; c.insets = new Insets(0, 0, 0, 16); // Leave 16 pixels so that we don't sit on top of the scroll-bar. frameLandscape.setLayer(sidePanel, JLayeredPane.PALETTE_LAYER); frameLandscape.add(sidePanel, c); addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Dimension dim = getSize(); if (dim != null) { // TODO: The following shouldn't be necessary, but it seems to be. int expectedWidth = frameLandscape.getWidth(); if (expectedWidth != graphPane.getWidth()) { Dimension goodSize = new Dimension(expectedWidth, graphPane.getHeight()); graphPane.setPreferredSize(goodSize); graphPane.setSize(goodSize); } setLegendVisible(true); } } }); //add graphPane to all cells c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.gridheight = 1; c.insets = new Insets(0, 0, 0, 0); frameLandscape.setLayer(scrollPane, JLayeredPane.DEFAULT_LAYER); frameLandscape.add(scrollPane, c); // Add our progress-panel. If setTracks is called promptly, it will be cleared // away before it ever has a chance to draw. getContentPane().add(new ProgressPanel(null), BorderLayout.CENTER); }
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);//from ww w . j a va2 s . co m 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:tk.tomby.tedit.core.Buffer.java
/** * Creates a new Buffer object./*from w w w . ja va 2 s.c o m*/ */ public Buffer() { super(); setLayout(new BorderLayout()); JPanel internalPanel = new JPanel(); internalPanel.setLayout(new BorderLayout()); editor = new ColourTextArea(); int red = PreferenceManager.getInt("general.editor.background.red", 0); int green = PreferenceManager.getInt("general.editor.background.green", 0); int blue = PreferenceManager.getInt("general.editor.background.blue", 0); editor.setBackground(new Color(red, green, blue)); red = PreferenceManager.getInt("general.editor.foreground.red", 0); green = PreferenceManager.getInt("general.editor.foreground.green", 0); blue = PreferenceManager.getInt("general.editor.foreground.blue", 0); editor.setForeground(new Color(red, green, blue)); red = PreferenceManager.getInt("general.editor.selection.red", 0); green = PreferenceManager.getInt("general.editor.selection.green", 0); blue = PreferenceManager.getInt("general.editor.selection.blue", 0); editor.setSelectionColor(new Color(red, green, blue)); String font = PreferenceManager.getString("general.editor.font", "Monospaced"); int size = PreferenceManager.getInt("general.editor.fontSize", 12); editor.setFont(new Font(font, Font.PLAIN, size)); editor.setEditable(true); editor.setDragEnabled(true); editor.setEditorKit(EditorKitManager.createEditorKit(getExtension(DEFAULT_FILE_NAME))); InputMap map = editor.getInputMap(JComponent.WHEN_FOCUSED); for (InputMap imap = map; imap != null; imap = imap.getParent()) { imap.remove(KeyStroke.getKeyStroke('V', InputEvent.CTRL_MASK, false)); imap.remove(KeyStroke.getKeyStroke('C', InputEvent.CTRL_MASK, false)); imap.remove(KeyStroke.getKeyStroke('X', InputEvent.CTRL_MASK, false)); imap.remove(KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK, false)); } editor.setInputMap(JComponent.WHEN_FOCUSED, map); editor.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent evt) { MessageManager.sendMessage(new BufferMessage(evt.getSource(), BufferMessage.CARET_EVENT)); } }); internalPanel.add(BorderLayout.CENTER, editor); if (PreferenceManager.getBoolean("general.editor.lineNumbers", false)) { lines = new LineNumbering(); lines.setPreferredSize(new Dimension(50, 0)); lines.setFont(new Font(font, Font.PLAIN, size)); lines.setFocusable(false); lines.setDocument(editor.getDocument()); internalPanel.add(BorderLayout.WEST, lines); } JScrollPane scroll = new JScrollPane(internalPanel); scroll.getVerticalScrollBar().setUnitIncrement(10); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scroll.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); add(BorderLayout.CENTER, scroll); editor.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { if (evt.isPopupTrigger()) { WorkspaceManager.getPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); } } public void mouseReleased(MouseEvent evt) { if (evt.isPopupTrigger()) { WorkspaceManager.getPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); } } }); undo = new UndoManager(); undoableListener = new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent evt) { undo.addEdit(evt.getEdit()); MessageManager.sendMessage(new BufferMessage(evt.getSource(), BufferMessage.UNDOABLE_EDIT_EVENT)); if (!modifiedState) { setModifiedState(true); } } }; editor.getDocument().addUndoableEditListener(undoableListener); MessageManager.addMessageListener(MessageManager.PREFERENCE_GROUP_NAME, this); fileName = DEFAULT_FILE_NAME; }
From source file:tk.tomby.tedit.plugins.explorer.Explorer.java
/** * Creates a new Explorer object./*from ww w. j a v a 2s . c om*/ */ public Explorer() { super("Explorer"); File rootDir = new File(PreferenceManager.getString("explorer.directory", System.getProperty("user.home"))); JPanel internalPanel = new JPanel(); internalPanel.setLayout(new BorderLayout()); topPanel = new TopPanel(rootDir.getAbsolutePath()); topPanel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JComboBox combo = (JComboBox) evt.getSource(); TaskManager.execute(new ReadDirectoryWorker(combo)); } }); internalPanel.add(BorderLayout.NORTH, topPanel); DefaultMutableTreeNode directoryRoot = new DefaultMutableTreeNode(rootDir); directoryTreeModel = new ShortedTreeModel(directoryRoot, new ToStringComparator()); directoryTree = new JTree(directoryTreeModel); directoryTree.setCellRenderer(new DirectoryCellRenderer()); directoryTree.setRootVisible(true); directoryTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); directoryTree.setEnabled(true); directoryTree.setEditable(false); directoryTree.setShowsRootHandles(true); directoryTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getPath(); TreePath leadPath = evt.getNewLeadSelectionPath(); if ((path != null) && (leadPath != null)) { TaskManager.execute(new RefreshWorker(leadPath, false)); } } }); directoryTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) directoryTree .getLastSelectedPathComponent(); if (!node.isRoot()) { File dir = (File) node.getUserObject(); topPanel.setDirectory(dir.getAbsolutePath()); } } } }); JScrollPane directoryScroll = new JScrollPane(directoryTree); directoryScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); directoryScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); directoryScroll.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); fileListModel = new ShortedListModel(new ToStringComparator()); fileList = new JList(fileListModel); fileList.setDragEnabled(true); fileList.setCellRenderer(new FileCellRenderer()); fileList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { final int index = fileList.locationToIndex(evt.getPoint()); TaskManager.execute(new Runnable() { public void run() { File file = (File) fileListModel.getElementAt(index); if (log.isDebugEnabled()) { log.debug(file); } IBuffer buffer = new BufferFactory().createBuffer(); buffer.open(file); WorkspaceManager.addBuffer(buffer); } }); } } }); JScrollPane filesScroll = new JScrollPane(fileList); filesScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); filesScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); filesScroll.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); splitPane = new StrippedSplitPane(JSplitPane.VERTICAL_SPLIT, directoryScroll, filesScroll); splitPane.setBorder(BorderFactory.createEmptyBorder()); splitPane.setOneTouchExpandable(false); splitPane.setDividerSize(5); splitPane.setDividerLocation(PreferenceManager.getInt("explorer.divider", 0)); List<MutableTreeNode> dirs = openDirectory(rootDir); directoryTreeModel.insertAllInto(dirs, directoryRoot); List<File> files = getFiles(rootDir); fileListModel.addAll(files); directoryTree.expandRow(0); internalPanel.add(splitPane, BorderLayout.CENTER); setContent(internalPanel); }
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//from ww w . j a v a 2 s. c o m 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: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// w w w .j av a 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); } }); }