List of usage examples for javax.swing JScrollPane setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:com.raceup.fsae.test.TesterGui.java
/** * Shows dialog with info about successful test submission *///from w w w. j a v a2 s . co m private void showSuccessfulTestSubmissionDialog() { String testSummary = test.toString(); StringBuilder message = new StringBuilder(testSummary + "\n" + "More" + " info below." + "\n"); for (String testResult : results) { message.append("\n").append(testResult).append("\n"); } JTextArea textArea = new JTextArea(message.toString()); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setPreferredSize(this.getSize()); JOptionPane.showMessageDialog(this, scrollPane, "Wonderful! You did it!", JOptionPane.INFORMATION_MESSAGE); }
From source file:Visuals.RingChart.java
public JPanel addDefenceCharts() { lowValue = "Low (" + low + ")"; ChartPanel ringPanel = drawRingChart(); ringPanel.setDomainZoomable(true);/* w w w . ja va2 s . c o m*/ JPanel thisRingPanel = new JPanel(); thisRingPanel.setLayout(new BorderLayout()); String[][] finalRisks = new String[riskCount][4]; for (int i = 0; i < riskCount; i++) { finalRisks[i][0] = risks[i][0]; finalRisks[i][1] = risks[i][1]; finalRisks[i][2] = risks[i][2]; finalRisks[i][3] = risks[i][3]; } JTable table = new JTable(finalRisks, networkDefenceColumns); TableColumn tcol = table.getColumnModel().getColumn(2); table.removeColumn(tcol); table.setEnabled(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int width = 0; for (int row = 0; row < table.getRowCount(); row++) { TableCellRenderer renderer = table.getCellRenderer(row, 1); Component comp = table.prepareRenderer(renderer, row, 1); width = Math.max(comp.getPreferredSize().width, width); } table.getColumnModel().getColumn(1).setPreferredWidth(width); width = 0; for (int row = 0; row < table.getRowCount(); row++) { TableCellRenderer renderer = table.getCellRenderer(row, 2); Component comp = table.prepareRenderer(renderer, row, 2); width = Math.max(comp.getPreferredSize().width, width); } table.getColumnModel().getColumn(2).setPreferredWidth(width); table.setShowHorizontalLines(true); table.setRowHeight(40); JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Dimension d = table.getPreferredSize(); tableScrollPane .setPreferredSize(new Dimension((d.width - 400), (table.getRowHeight() + 1) * (riskCount + 1))); JLabel right = new JLabel( " "); thisRingPanel.add(right, BorderLayout.EAST); thisRingPanel.add(ringPanel, BorderLayout.CENTER); thisRingPanel.add(tableScrollPane, BorderLayout.SOUTH); return thisRingPanel; }
From source file:net.sf.firemox.ui.component.SplashScreen.java
/** * Create a new instance of this class./*from w w w.j a va 2s . co m*/ * * @param filename * the picture filename. * @param parent * the splash screen's parent. * @param waitTime * the maximum time before the screen is hidden. */ public SplashScreen(String filename, Frame parent, int waitTime) { super(parent); getContentPane().setLayout(null); toFront(); final JLabel l = new JLabel(new ImageIcon(filename)); final Dimension labelSize = l.getPreferredSize(); l.setLocation(0, 0); l.setSize(labelSize); setSize(labelSize); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - labelSize.width / 2, screenSize.height / 2 - labelSize.height / 2); final JLabel mp = new JLabel(IdConst.PROJECT_DISPLAY_NAME); mp.setLocation(30, 305); mp.setSize(new Dimension(300, 30)); final JLabel version = new JLabel(IdConst.VERSION); version.setLocation(235, 418); version.setSize(new Dimension(300, 30)); final JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setFont(MToolKit.defaultFont); disclaimer.setTabSize(2); // Then try and read it locally Reader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } final JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); disclaimerSPanel.setViewportView(disclaimer); disclaimerSPanel.setLocation(27, 340); disclaimerSPanel.setPreferredSize(new Dimension(283, 80)); disclaimerSPanel.setSize(disclaimerSPanel.getPreferredSize()); getContentPane().add(disclaimerSPanel); getContentPane().add(version); getContentPane().add(mp); getContentPane().add(l); final int pause = waitTime; final Runnable waitRunner = new Runnable() { public void run() { try { Thread.sleep(pause); while (!bKilled) { Thread.sleep(200); } } catch (InterruptedException e) { // Ignore this error } setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } }; // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { setVisible(false); dispose(); if (MagicUIComponents.magicForm != null) MagicUIComponents.magicForm.toFront(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { setVisible(false); dispose(); MagicUIComponents.magicForm.toFront(); } } }); setVisible(true); start(waitRunner); }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformQQNormalPlotChart.java
protected void setTable(XYDataset ds) { convertor.data2Table(raw_y, transformed_x, "Data", "Transformed Data", row_count); //convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); resetTableRows(tempDataTable.getRowCount()); resetTableColumns(tempDataTable.getColumnCount()); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i)); // System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i)); }// ww w. ja v a 2 s .c o m columnModel = dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); for (int i = 0; i < tempDataTable.getRowCount(); i++) for (int j = 0; j < tempDataTable.getColumnCount(); j++) { dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j); } dataPanel.removeAll(); JScrollPane dt = new JScrollPane(dataTable); dataPanel.add(dt); dt.setRowHeaderView(headerTable); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } dataPanel.validate(); // don't bring graph to the front if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) { // tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel)); } else { dataPanel2.removeAll(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Data")); JScrollPane dt2 = new JScrollPane(dataTable); dt2.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8)); dt2.setRowHeaderView(headerTable); dataPanel2.add(dt2); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6)); dataPanel2.add(st); st.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Mapping")); mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2)); dataPanel2.add(mapPanel); dataPanel2.validate(); } }
From source file:edu.ucla.stat.SOCR.chart.demo.DotChart.java
protected void setMixPanel() { dataPanel2.removeAll();//from w w w. ja v a 2 s .c om graphPanel2.removeAll(); graphPanel2.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3)); graphPanel2.setLayout(new BoxLayout(graphPanel2, BoxLayout.Y_AXIS)); if (chartPanel1 != null) graphPanel2.add(chartPanel1); if (chartPanel2 != null) graphPanel2.add(chartPanel2); graphPanel2.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Data")); JScrollPane dt = new JScrollPane(dataTable); dt.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8)); dataPanel2.add(dt); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6)); dataPanel2.add(st); st.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Mapping")); mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2)); dataPanel2.add(mapPanel); dataPanel2.validate(); mixPanel.removeAll(); mixPanel.add(graphPanel2, BorderLayout.WEST); mixPanel.add(new JScrollPane(dataPanel2), BorderLayout.CENTER); mixPanel.validate(); }
From source file:com.floreantpos.ui.forms.QuickCustomerForm.java
private void createCustomerForm() { setLayout(new BorderLayout(10, 10)); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setOpaque(true);/* w w w .ja v a2s. c o m*/ JPanel inputPanel = new JPanel(); inputPanel.setLayout(new MigLayout("insets 10 10 10 10", "[][][][]", "[][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ inputPanel.setBorder(BorderFactory.createTitledBorder("Enter Customer Information")); JLabel lblAddress = new JLabel(Messages.getString("CustomerForm.18")); //$NON-NLS-1$ tfAddress = new JTextArea(new FixedLengthDocument(220)); JScrollPane scrlDescription = new JScrollPane(tfAddress); scrlDescription.setPreferredSize(PosUIManager.getSize(338, 52)); JLabel lblZip = new JLabel(Messages.getString("CustomerForm.21")); //$NON-NLS-1$ tfZip = new FixedLengthTextField(30); JLabel lblCitytown = new JLabel(Messages.getString("CustomerForm.24")); //$NON-NLS-1$ tfCity = new FixedLengthTextField(); JLabel lblState = new JLabel(Messages.getString("QuickCustomerForm.0")); //$NON-NLS-1$ tfState = new JTextField(30); JLabel lblCellPhone = new JLabel(Messages.getString("CustomerForm.32")); //$NON-NLS-1$ inputPanel.add(lblCellPhone, "cell 0 1,alignx right"); //$NON-NLS-1$ tfCellPhone = new JTextField(30); inputPanel.add(tfCellPhone, "cell 1 1"); //$NON-NLS-1$ //setPreferredSize(PosUIManager.getSize(800, 350)); JLabel lblFirstName = new JLabel(Messages.getString("CustomerForm.3")); //$NON-NLS-1$ //inputPanel.add(lblFirstName, "cell 0 2,alignx right"); //$NON-NLS-1$ tfFirstName = new FixedLengthTextField(); //inputPanel.add(tfFirstName, "cell 1 2"); //$NON-NLS-1$ JLabel lblLastName = new JLabel(Messages.getString("CustomerForm.11")); //$NON-NLS-1$ //inputPanel.add(lblLastName, "cell 0 3,alignx right"); //$NON-NLS-1$ tfLastName = new FixedLengthTextField(); //inputPanel.add(tfLastName, "cell 1 3"); //$NON-NLS-1$ JLabel lblName = new JLabel("Name"); //$NON-NLS-1$ inputPanel.add(lblName, "cell 0 3,alignx right"); //$NON-NLS-1$ tfName = new FixedLengthTextField(); tfName.setLength(120); inputPanel.add(tfName, "cell 1 3"); //$NON-NLS-1$ inputPanel.add(lblZip, "cell 0 4,right"); //$NON-NLS-1$ inputPanel.add(tfZip, "cell 1 4"); //$NON-NLS-1$ inputPanel.add(lblCitytown, "cell 0 5,right"); //$NON-NLS-1$ inputPanel.add(tfCity, "cell 1 5"); //$NON-NLS-1$ inputPanel.add(lblState, "cell 0 6,right"); //$NON-NLS-1$ inputPanel.add(tfState, "cell 1 6"); //$NON-NLS-1$ inputPanel.add(lblAddress, "cell 2 1 1 6,right"); //$NON-NLS-1$ inputPanel.add(scrlDescription, "grow, cell 3 1 1 6"); //$NON-NLS-1$ qwertyKeyPad = new QwertyKeyPad(); add(inputPanel, BorderLayout.CENTER); if (isKeypad) { add(qwertyKeyPad, BorderLayout.SOUTH); //$NON-NLS-1$ } tfZip.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getStateAndCityByZipCode(); } }); tfZip.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { getStateAndCityByZipCode(); } @Override public void focusGained(FocusEvent e) { } }); enableCustomerFields(false); callOrderController(); }
From source file:net.sourceforge.atunes.kernel.modules.state.RepositoryPanel.java
/** * Add components to panel/* www . ja v a 2 s. c om*/ */ private void setupPanel() { GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 0; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 10, 0, 0); add(new JLabel(I18nUtils.getString("REPOSITORY_REFRESH_TIME")), c); c.gridx = 1; c.weightx = 1; c.insets = new Insets(0, 10, 0, 0); add(this.refreshTime, c); c.gridx = 0; c.gridy = 1; c.weightx = 1; c.insets = new Insets(10, 10, 0, 0); add(new JLabel(I18nUtils.getString("COMMAND_BEFORE_REPOSITORY_ACCESS")), c); c.gridx = 1; c.weightx = 1; add(this.commandBeforeAccessRepository, c); c.gridx = 0; c.gridy = 2; c.weightx = 0; add(new JLabel(I18nUtils.getString("COMMAND_AFTER_REPOSITORY_ACCESS")), c); c.gridx = 1; c.weightx = 1; add(this.commandAfterAccessRepository, c); c.gridx = 0; c.gridy = 3; c.insets = new Insets(20, 10, 0, 0); JScrollPane scrollPane = this.controlsBuilder.createScrollPane(this.repositoryFoldersList); scrollPane.setMinimumSize(new Dimension(400, 300)); scrollPane.setPreferredSize(new Dimension(400, 300)); add(scrollPane, c); JPanel addRemovePanel = new JPanel(new GridLayout(1, 2, 5, 0)); addRemovePanel.add(this.addFolderButton); addRemovePanel.add(this.removeFolderButton); c.gridy = 4; c.insets = new Insets(10, 10, 0, 0); add(addRemovePanel, c); c.gridx = 0; c.gridy = 5; c.weighty = 1; c.anchor = GridBagConstraints.NORTHWEST; add(this.useRatingsStoredInTag, c); }
From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java
/** * Constructor//from w w w.ja v a2s.c om * * @param compactLayout * if false, there will be message type selectors in the panel */ public VOCTAdditionalInfoPanel(boolean compactLayout) { super(new BorderLayout()); EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this); // Prepare the title header titleHeader.setBackground(getBackground().darker()); titleHeader.setOpaque(true); titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); titleHeader.setHorizontalAlignment(SwingConstants.CENTER); add(titleHeader, BorderLayout.NORTH); // Add messages panel scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); messagesPanel.setBackground(UIManager.getColor("List.background")); messagesPanel.setOpaque(false); messagesPanel.setLayout(new GridBagLayout()); messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(scrollPane, BorderLayout.CENTER); JPanel sendPanel = new JPanel(new GridBagLayout()); add(sendPanel, BorderLayout.SOUTH); Insets insets = new Insets(2, 2, 2, 2); // Add text area // if (false) { // messageText = new JTextField(); // ((JTextField) messageText).addActionListener(this); // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // // } else { messageText = new JTextArea(); JScrollPane scrollPane2 = new JScrollPane(messageText); scrollPane2.setPreferredSize(new Dimension(100, 50)); scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // } // Add buttons // ButtonGroup group = new ButtonGroup(); if (!compactLayout) { JToolBar msgTypePanel = new JToolBar(); msgTypePanel.setBorderPainted(false); msgTypePanel.setOpaque(true); msgTypePanel.setFloatable(false); sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } if (compactLayout) { addBtn = new JButton("Add to Log"); sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } // addBtn.setEnabled(false); // messageText.setEditable(false); addBtn.addActionListener(this); }
From source file:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);//w ww .j av a2 s . c o m //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:Console.java
public Console(Process p) { JFrame frame = new JFrame(); frame.setTitle("Console"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(screenSize.width / 2 - INITIAL_WIDTH / 2, screenSize.height / 2 - INITIAL_HEIGHT / 2); ConsoleTextArea cta = new ConsoleTextArea(); JScrollPane scroll = new JScrollPane(cta); scroll.setPreferredSize(new Dimension(INITIAL_WIDTH, INITIAL_HEIGHT)); frame.getContentPane().add(scroll);/*ww w . j a v a2 s. c om*/ frame.pack(); // From here down your shell should be pretty much // as it is written here! /* * Start up StdOut, StdIn and StdErr threads that write the output generated by the process * p to the screen, and feed the keyboard input into p. */ so = new StdOut(p, cta); se = new StdOut(p, cta); StdIn si = new StdIn(p, cta); so.start(); se.start(); si.start(); // Wait for the process p to complete. try { frame.setVisible(true); p.waitFor(); } catch (InterruptedException e) { /* * Something bad happened while the command was executing. */ System.out.println("Error during execution"); System.out.println(e); } /* * Now signal the StdOut, StdErr and StdIn threads that the process is done, and wait for * them to complete. */ try { so.done(); se.done(); si.done(); so.join(); se.join(); si.join(); } catch (InterruptedException e) { // Something bad happend to one of the Std threads. System.out.println("Error in StdOut, StdErr or StdIn."); System.out.println(e); } frame.setVisible(false); }