private static void badFetch() { final JFrame frame = new JFrame("TestFetchWebGui"); final JPanel outerPanel = new JPanel(), buttonPanel = new JPanel(); final JButton fetchButton = new JButton("Fetch"), cancelButton = new JButton("Cancel"); frame.add(outerPanel); outerPanel.setLayout(new BorderLayout()); buttonPanel.setLayout(new GridLayout(2, 1)); buttonPanel.add(fetchButton); buttonPanel.add(cancelButton); outerPanel.add(buttonPanel, BorderLayout.EAST); final TextArea textArea = new TextArea(25, 80); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); outerPanel.add(textArea, BorderLayout.WEST); fetchButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { for (String url : urls) { System.out.println("Fetching " + url); String page = getPage(url, 200); textArea.append(String.format("%-40s%7d%n", url, page.length())); } } }); frame.pack(); frame.setVisible(true); }
void setCutText(String text) { selection = text; textArea.setText(text); if (isVisible()) { textArea.selectAll(); } }
public Irc(Sentence_itf s) { setLayout(new FlowLayout()); text = new TextArea(10, 60); text.setEditable(false); text.setForeground(Color.red); add(text); data = new TextField(60); add(data); Button write_button = new Button("write"); write_button.addActionListener(new writeListener(this)); add(write_button); Button read_button = new Button("read"); read_button.addActionListener(new readListener(this)); add(read_button); setSize(470, 300); text.setBackground(Color.black); show(); sentence = s; }
/** * IRC Constructor * * @param jo the JVN object representing the Chat */ public Irc(JvnObject jo) { sentence = jo; frame = new JFrame(); frame.setLayout(new GridLayout(1, 1)); text = new TextArea(10, 60); text.setEditable(false); text.setForeground(Color.red); frame.add(text); data = new TextField(40); frame.add(data); Button read_button = new Button("read"); read_button.addActionListener(new readListener(this)); frame.add(read_button); Button write_button = new Button("write"); write_button.addActionListener(new writeListener(this)); frame.add(write_button); frame.setSize(545, 201); // frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("Closed"); try { JvnServerImpl.jvnGetServer().jvnTerminate(); } catch (Exception exc) { System.out.println("An exception: " + exc); } e.getWindow().dispose(); } }); text.setBackground(Color.black); frame.setVisible(true); }
void jbInit() throws Exception { panel1.setLayout(borderLayout1); panel2.setBackground(Color.yellow); panel2.setLayout(borderLayout2); ButtonOK.setLabel("OK"); ButtonOK.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { ButtonOK_mouseClicked(e); } }); String s1 = CallingApp.MotherApplet.GetName(); textArea1.setBackground(SystemColor.control); textArea1.setEditable(false); panel1.add(panel2, BorderLayout.CENTER); panel2.add(textArea1, BorderLayout.CENTER); panel1.add(panel3, BorderLayout.SOUTH); panel3.add(ButtonOK, null); String s = s1 + " v:" + CallingApp.MotherApplet.GetVersionNum() + "\n" + CallingApp.MotherApplet.GetInfos(); textArea1.setText(s); }
/*.................................................................................................................*/ public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("setToDefaults")) { setDefaultTNTCommandsSearchOptions(); searchField.setText(searchArguments); bootstrapSearchField.setText(bootstrapSearchArguments); harvestOnlyStrictConsensusBox.setState(harvestOnlyStrictConsensus); resamplingAllConsensusTreesBox.setState(!resamplingAllConsensusTrees); bootStrapRepsField.setValue(bootstrapreps); } else if (e.getActionCommand().equalsIgnoreCase("setToDefaultsOtherOptions")) { setDefaultTNTCommandsOtherOptions(); otherOptionsField.setText(otherOptions); convertGapsBox.setState(convertGapsToMissing); } else if (e.getActionCommand().equalsIgnoreCase("browseSearchScript") && searchScriptPathField != null) { MesquiteString directoryName = new MesquiteString(); MesquiteString fileName = new MesquiteString(); String path = MesquiteFile.openFileDialog("Choose Search Script File", directoryName, fileName); if (StringUtil.notEmpty(path)) searchScriptPathField.setText(path); } else if (e.getActionCommand().equalsIgnoreCase("browseBootSearchScript") && bootSearchScriptPathField != null) { MesquiteString directoryName = new MesquiteString(); MesquiteString fileName = new MesquiteString(); String path = MesquiteFile.openFileDialog( "Choose Resampling Search Script File", directoryName, fileName); if (StringUtil.notEmpty(path)) bootSearchScriptPathField.setText(path); } }
/** Returns the contents of the next textarea. */ public String getNextText() { String text; if (textAreaIndex == 0 && textArea1 != null) { // textArea1.selectAll(); text = textArea1.getText(); textAreaIndex++; if (macro) text = Macro.getValue(macroOptions, "text1", text); if (recorderOn) { String text2 = text; String cmd = Recorder.getCommand(); if (cmd != null && cmd.equals("Convolve...")) { text2 = text.replaceAll("\n", "\\\\n"); if (!text.endsWith("\n")) text2 = text2 + "\\n"; } else text2 = text.replace('\n', ' '); Recorder.recordOption("text1", text2); } } else if (textAreaIndex == 1 && textArea2 != null) { textArea2.selectAll(); text = textArea2.getText(); textAreaIndex++; if (macro) text = Macro.getValue(macroOptions, "text2", text); if (recorderOn) Recorder.recordOption("text2", text.replace('\n', ' ')); } else text = null; return text; }
// DO NOT call this directly, go through Sysout public void printInstructions(String[] instructions) { // Clear out any current instructions instructionsText.setText(""); // Go down array of instruction strings String printStr, remainingStr; for (int i = 0; i < instructions.length; i++) { // chop up each into pieces maxSringLength long remainingStr = instructions[i]; while (remainingStr.length() > 0) { // if longer than max then chop off first max chars to print if (remainingStr.length() >= maxStringLength) { // Try to chop on a word boundary int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1); if (posOfSpace <= 0) posOfSpace = maxStringLength - 1; printStr = remainingStr.substring(0, posOfSpace + 1); remainingStr = remainingStr.substring(posOfSpace + 1); } // else just print else { printStr = remainingStr; remainingStr = ""; } instructionsText.append(printStr + "\n"); } // while } // for } // printInstructions()
public void startServer() throws Exception { while (true) { Socket s = server.accept(); cClient.add(new ClientConn(s)); ta.append("NEW-CLIENT " + s.getInetAddress() + ":" + s.getPort()); ta.append("\n" + "CLIENTS-COUNT: " + cClient.size() + "\n\n"); } }
/** Method declaration Adjust this method for large strings...ie multi megabtypes. */ void execute() { String sCmd = null; if (4096 <= ifHuge.length()) { sCmd = ifHuge; } else { sCmd = txtCommand.getText(); } if (sCmd.startsWith("-->>>TEST<<<--")) { testPerformance(); return; } String g[] = new String[1]; lTime = System.currentTimeMillis(); try { sStatement.execute(sCmd); lTime = System.currentTimeMillis() - lTime; int r = sStatement.getUpdateCount(); if (r == -1) { formatResultSet(sStatement.getResultSet()); } else { g[0] = "update count"; gResult.setHead(g); g[0] = String.valueOf(r); gResult.addRow(g); } addToRecent(txtCommand.getText()); } catch (SQLException e) { lTime = System.currentTimeMillis() - lTime; g[0] = "SQL Error"; gResult.setHead(g); String s = e.getMessage(); s += " / Error Code: " + e.getErrorCode(); s += " / State: " + e.getSQLState(); g[0] = s; gResult.addRow(g); } updateResult(); System.gc(); }
public void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.black); this.setSize(650, 600); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {} }); /** ************************* MAIN PANEL ******************************* */ mainPanel = new JPanel(); // If put to False: we see the container's background mainPanel.setOpaque(false); mainPanel.setLayout(new BorderLayout()); container.add(mainPanel, BorderLayout.CENTER); allmessagesTextArea = new TextArea(); allmessagesTextArea.setEditable(false); allmessagesTextArea.setFont(new Font("Dialog", 1, 12)); allmessagesTextArea.setForeground(Color.black); allmessagesTextArea.append("Select a session in the list to view its messages"); mainPanel.add(allmessagesTextArea, BorderLayout.CENTER); sessionsList = new List(); sessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { showMessages(e); } }); sessionsList.setForeground(Color.black); sessionsList.setFont(new Font("Dialog", 1, 14)); mainPanel.add(sessionsList, BorderLayout.WEST); okButton = new JButton(" OK "); okButton.setToolTipText("Returns to the main frame"); okButton.setFont(new Font("Dialog", 1, 16)); okButton.setFocusPainted(false); okButton.setBackground(Color.lightGray); okButton.setBorder(new BevelBorder(BevelBorder.RAISED)); okButton.setVerticalAlignment(SwingConstants.CENTER); okButton.setHorizontalAlignment(SwingConstants.CENTER); container.add(okButton, BorderLayout.SOUTH); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setVisible(false); } }); }
/** Method declaration */ private void initGUI() { Panel pQuery = new Panel(); Panel pCommand = new Panel(); pResult = new Panel(); pQuery.setLayout(new BorderLayout()); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new TextArea(5, 40); txtCommand.addKeyListener(this); txtResult = new TextArea(20, 40); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); butExecute = new Button("Execute"); butClear = new Button("Clear"); butExecute.addActionListener(this); butClear.addActionListener(this); pCommand.add("East", butExecute); pCommand.add("West", butClear); pCommand.add("Center", txtCommand); gResult = new Grid(); setLayout(new BorderLayout()); pResult.add("Center", gResult); pQuery.add("North", pCommand); pQuery.add("Center", pResult); fMain.add("Center", pQuery); tTree = new Tree(); // (ulrivo): screen with less than 640 width Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (d.width >= 640) { tTree.setMinimumSize(new Dimension(200, 100)); } else { tTree.setMinimumSize(new Dimension(80, 100)); } gResult.setMinimumSize(new Dimension(200, 300)); fMain.add("West", tTree); doLayout(); fMain.pack(); }
/** * Method declaration * * @param s * @param help */ void showHelp(String help[]) { txtCommand.setText(help[0]); txtResult.setText(help[1]); bHelp = true; pResult.removeAll(); pResult.add("Center", txtResult); pResult.doLayout(); txtCommand.requestFocus(); txtCommand.setCaretPosition(help[0].length()); }
/** * opens the chosen file, reads in the file, and prints out a receipt * * @param chosenFile */ private void readSource(File chosenFile) { String chosenFileName = chosenFile.getName(); TextFileInput inFile = new TextFileInput(chosenFileName); Container myContentPane = jframe.getContentPane(); // chosenFile TextArea myTextArea = new TextArea(); myContentPane.add(myTextArea); int count = 0; float priceTotal = 0.0f; Database db = new Database("database2.txt"); String[] transaction = new String[100]; String line = inFile.readLine(); DecimalFormat df = new DecimalFormat("#00.00"); while (line != null) { StringTokenizer tokenized = new StringTokenizer(line, ","); String code = tokenized.nextToken(); float weight = Float.parseFloat(tokenized.nextToken()); String name; float price; try { name = db.getName(code); } catch (ItemNotFoundException e) { name = JOptionPane.showInputDialog(null, "Item " + code + " not found. Enter Name: "); } try { price = db.getPrice(code); } catch (ItemNotFoundException e) { price = Float.valueOf( JOptionPane.showInputDialog( null, "Price for " + name + " not found. Enter price: ")); } float itemTotal = weight * price; priceTotal += itemTotal; transaction[count] = name + "\t" + price + "\t" + df.format(weight) + "\t $" + df.format(itemTotal); count++; line = inFile.readLine(); } // while myTextArea.setText("ITEM: \t PRICE\\LB: \t POUNDS: \t TOTAL:"); myTextArea.append("\n"); for (int i = 0; i < count; i++) { myTextArea.append(transaction[i]); myTextArea.append("\n"); } myTextArea.append("\t\t TOTAL: $" + df.format(priceTotal)); jframe.setVisible(true); } // openFile
/** Creates new HelpBox */ public HelpBox() { super(new Frame(), " Help ", false); this.setBackground(Color.white); this.setLayout(new BorderLayout()); helpTextArea = new TextArea(); helpTextArea.setEditable(false); // fill the help box helpTextArea.append( "National Institute of Standards and Technology\n" + "========================================\n" + "\n" + "NIST-SIP Trace viewer 1.1\n" + "========================================\n" + "\n" + "\n" + " Hit refresh to get new trace data from the proxy. \n" + "If no traces appear at all, you should check if the proxy is started.\n" + "Once some SIP sessions are available, you can click directly on \n" + "an arrow representing a SIP message of your \n" + "choice, and see the text of the chosen SIP message. \n" + "If any small yellow bubbles appear on the top right of the SIP message, \n" + "you can click on it and see some extra informations logged by the proxy.\n" + "\n" + "\n" + "If you experience any problems please contact:\n" + "[email protected]\n" + "\n"); ok = new Button(" Ok "); ok.setBackground(Color.lightGray); ok.setForeground(Color.black); this.add(helpTextArea, BorderLayout.CENTER); this.add(ok, BorderLayout.SOUTH); ok.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { setVisible(false); } }); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { setVisible(false); } }); // width, height this.setSize(400, 400); }
public void actionPerformed(ActionEvent e) { chooser = new JFileChooser(); chooser.setCurrentDirectory(new File("C:\\Program Files (x86)\\Tango04\\Dashboards\\Web")); chooser.setDialogTitle("Browse..."); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { textArea.setText(""); new Exportator().startExporting(chooser.getSelectedFile().getPath(), textArea); } else { textArea.setText("No Selection"); } }
public void actionPerformed(ActionEvent evt) { if (evt.getSource() == clearButton) { textArea.setText(""); } else if (evt.getSource() == closeButton) { setVisible(false); } }
/** This is the action listener method that the menu items invoke */ public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("quit")) { YesNoDialog d = new YesNoDialog( this, "Really Quit?", "Are you sure you want to quit?", "Yes", "No", null); d.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("yes")) System.exit(0); else textarea.append("Quit not confirmed\n"); } }); d.show(); } else if (command.equals("open")) { FileDialog d = new FileDialog(this, "Open File", FileDialog.LOAD); d.show(); // display the dialog and block until answered textarea.append("You selected file: " + d.getFile() + "\n"); d.dispose(); } else if (command.equals("about")) { InfoDialog d = new InfoDialog( this, "About", "This demo was written by David Flanagan\n" + "Copyright (c) 1997 O'Reilly & Associates"); d.show(); } }
String[] getContactList() { java.util.List cl = new java.util.LinkedList(); StringTokenizer st = new StringTokenizer(contactList.getText()); StringBuffer sb = new StringBuffer(); StringBuffer dbg = new StringBuffer("test applet contactlist: "); while (st.hasMoreTokens()) { String loginId = st.nextToken().trim(); if (loginId.length() == 0) continue; dbg.append("'" + loginId + "' "); cl.add(loginId); sb.append(loginId).append('\n'); } CAT.info(dbg.toString()); contactList.setText(sb.toString()); return (String[]) cl.toArray(new String[cl.size()]); }
void login() { try { logoutBtn.setEnabled(true); contactList.setEditable(false); loginBtn.setEnabled(false); loginId.setEnabled(false); password.setEnabled(false); // plugin.login( getMyLoginId(), password.getText(), getContactList(), MessagingNetwork.STATUS_ONLINE); logoutBtn.setEnabled(true); } catch (Throwable tr) { printException(tr); boolean loggedIn = false; try { loggedIn = plugin.getClientStatus(getMyLoginId()) != MessagingNetwork.STATUS_OFFLINE; } catch (Throwable tr2) { printException(tr2); } if (!loggedIn) { enableLoginUI(); } } }
public void frameInit() { ta.setBackground(Color.white); p = new Panel(); p2 = new Panel(); p3 = new Panel(); b = new Button("close"); status = new Label("Status:", Label.LEFT); p2.setLayout(new GridLayout(2, 1, 5, 5)); p2.add(status); p.setLayout(new FlowLayout()); p.add(b); p3.setLayout(new GridLayout(2, 1, 0, 0)); p3.add(p2); p3.add(p); setLayout(new BorderLayout()); add("Center", ta); add("South", p3); b.addActionListener(this); }
{ StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(cfg.REQPARAM_CONTACT_LIST_LOGIN_IDS, ","); while (st.hasMoreTokens()) { sb.append(st.nextToken()); if (st.hasMoreTokens()) sb.append("\n"); } contactList.setText(sb.toString()); }
// Called in the event thread when done() has terminated, whether // by completing or by being cancelled. public void done() { try { textArea.append(get()); // textArea.append("Done"); } catch (InterruptedException exn) { } catch (ExecutionException exn) { throw new RuntimeException(exn.getCause()); } catch (CancellationException exn) { } // (3) }
public ReciveFile() { super("파일전송"); setLayout(null); lbl = new Label("파일 전송을 기다립니다."); lbl.setBounds(10, 30, 230, 20); lbl.setBackground(Color.gray); lbl.setForeground(Color.white); add(lbl); txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH); txt.setBounds(10, 60, 230, 100); txt.setEditable(false); add(txt); btn = new Button("닫기"); btn.setBounds(105, 170, 40, 20); btn.setVisible(false); btn.addActionListener(this); add(btn); addWindowListener(new WinListener()); setSize(250, 200); show(); try { ServerSocket socket = new ServerSocket(port); Socket sock = null; FileThread client = null; try { sock = socket.accept(); client = new FileThread(this, sock); client.start(); } catch (IOException e) { System.out.println(e); try { if (sock != null) sock.close(); } catch (IOException e1) { System.out.println(e1); } finally { sock = null; } } } catch (IOException e) { } }
void enableLoginUI() { try { logoutBtn.setEnabled(false); contactList.setEditable(true); loginBtn.setEnabled(true); loginId.setEnabled(true); password.setEnabled(true); } catch (Throwable tr) { CAT.error("exception", tr); } }
// Close socket and IO streams, change appearance/functionality of some components private void closeAll() throws IOException { displayArea.append("\nConnection closing"); output.close(); input.close(); connection.close(); // We are no longer connected connection = null; // Change components serverField.setEditable(true); connectButton.setLabel("Connect to server above"); enterField.setEnabled(false); }
/** * This method uses JEP's getValueAsObject() method to obtain the current value of the expression * entered. */ private void updateResult() { Object result; String errorInfo; // Get the value result = myParser.getValueAsObject(); // Is the result ok? if (result != null) { resultLabel.setText(result.toString()); } else { resultLabel.setText(""); } // Get the error information if ((errorInfo = myParser.getErrorInfo()) != null) { errorTextArea.setText(errorInfo); } else { errorTextArea.setText(""); } }
/** * Adds one or two (side by side) text areas. * * @param text1 initial contents of the first text area * @param text2 initial contents of the second text area or null * @param rows the number of rows * @param columns the number of columns */ public void addTextAreas(String text1, String text2, int rows, int columns) { if (textArea1 != null) return; Panel panel = new Panel(); textArea1 = new TextArea(text1, rows, columns, TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea1.setBackground(Color.white); textArea1.addTextListener(this); panel.add(textArea1); if (text2 != null) { textArea2 = new TextArea(text2, rows, columns, TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea2.setBackground(Color.white); panel.add(textArea2); } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(15, 20, 0, 0); grid.setConstraints(panel, c); add(panel); y++; }
public AppExport() { JLabel label = new JLabel("Choose Dashboard's Web directory: "); add(label); JButton go = new JButton("Browse..."); go.addActionListener(this); add(go); textArea = new TextArea("", 20, 100, TextArea.SCROLLBARS_NONE); textArea.setEditable(false); add(textArea); }
public void init() { Output.web = true; String opts = getParameter("opts"); if (opts != null) { almc lmc = new almc("-tdir=" + getCodeBase() + " " + opts); return; } setBackground(Color.black); setForeground(Color.lightGray); setLayout(new GridLayout(3, 1)); panel1 = new Panel1(this); add(panel1); panel2 = new Panel2(this); add(panel2); err = new TextArea(); err.setEditable(false); err.setBackground(Color.black); err.setForeground(Color.lightGray); add(err); stdReset(); out.append(Output.version + "\n\n"); err.append(Output.version + "\n"); par.append(Output.version + "\n"); Output.err.println("Running from " + getCodeBase()); }