List of usage examples for javax.swing JTextArea append
public void append(String str)
From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java
private void addDefaultTags(List<VariantTag> variantTags, JTextArea ta) { VariantTag tag1 = new VariantTag(VariantTag.UPLOADER, LoginController.getInstance().getUserName()); VariantTag tag2 = new VariantTag(VariantTag.UPLOAD_DATE, (new Date()).toString()); variantTags.add(tag1);// w w w.j a v a2 s . c om variantTags.add(tag2); ta.append(tag1.toString() + "\n"); ta.append(tag2.toString() + "\n"); }
From source file:spms.client.Solver.java
public void executePDDL(javax.swing.JTextArea t, javax.swing.JButton b) { //Through this method will call planner and give it generatorFile that chosen by client and receive planner output to be sent to the server System.out.println("STTTTTTTTTTTTTTTTTTTTTTTTT"); //TODO: call to planner software & send the generator file to planner String planner_path = "/home/yazeedalmusharraf/Desktop/gameProject/SPMS_Project/"; int randomNum = 1 + (int) (Math.random() * 1000); String path = planner_path + game.getGameName() + "/plan" + randomNum + ".pddl"; Runtime run = Runtime.getRuntime(); try {// www. j a va 2 s . c o m // System.out.println(planner_path+"planner/FF-v2.3/./ff -o "+planner_path+game.getGameName()+"/domain.pddl -f "+planner_path+game.getGameName()+"/genfile.pddl"); pddlProcces = run.exec(planner_path + "planner/FF-v2.3/./ff -o " + planner_path + game.getGameName() + "/domain.pddl -f " + planner_path + game.getGameName() + "/genfile.pddl"); BufferedReader d = new BufferedReader(new InputStreamReader(pddlProcces.getInputStream())); FileOutputStream out = new FileOutputStream(path); String line; while ((line = d.readLine()) != null) { t.append(line + "\n"); out.write(line.getBytes()); out.write("\n".getBytes()); } out.close(); String f = t.getText().replace("\n", SysConst.ENDL); b.setVisible(true); session.send(SysConst.SEND_FINISHED_GMAE + f); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:TrabajoFinalJava.FormularioVerFicheros.java
public void run() { //************************INICIO****INTERFAZ************************************************************************** JFrame principal = new JFrame("GESTOR DESCARGAS"); //Colores/*from w w w .j a v a2s . c om*/ Color nuevoColor = new Color(167, 220, 231); principal.getContentPane().setBackground(nuevoColor); JLabel tituloPrincipal = new JLabel("GESTOR DESCARGAS"); JLabel tituloVentana = new JLabel("VER FICHEROS"); JTextArea cajaFicheros = new JTextArea(12, 20); JButton mostrar = new JButton("MOSTRAR FICHEROS"); JButton atras = new JButton("ATRAS"); JButton salir = new JButton("SALIR"); cajaFicheros.setEditable(false); //Recojo la fuente que se esta utilizando actualmente. Font auxFont = tituloPrincipal.getFont(); //Aplico la fuente actual, y al final le doy el tamao del texto... tituloPrincipal.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); tituloVentana.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); //Asignamos la constante EXIT_ON_CLOSE, cierra la ventana al pulsar la X. principal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Asignamos al JFrame el Layout que usaremos, GridBagLayout principal.setLayout(gridbag); //aadir botones al layout gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(tituloPrincipal, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(tituloVentana, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(new JScrollPane(cajaFicheros), gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(mostrar, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(atras, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(salir, gbc); //cajaFicheros.setEditable(false); //Hace visible el panel principal.setVisible(true); principal.setSize(650, 350); principal.setLocationRelativeTo(null); principal.setResizable(false); //principal.pack(); mostrar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String ftpSsrver = "127.0.0.1"; String ftpUser = "solera"; String ftpPass = "solera"; FTPClient cFtp = new FTPClient(); try { cFtp.connect(ftpSsrver); boolean login = cFtp.login(ftpUser, ftpPass); System.out.print("conexion ftp para ver ficheros establecida"); cFtp.enterLocalPassiveMode(); String[] archivos = cFtp.listNames(); FTPFile[] detalles = cFtp.listFiles(); archivos = cFtp.listNames(); for (int i = 0; i < archivos.length; i++) { /* cajaFicheros.selectAll(); cajaFicheros.replaceSelection(""); */ arrayArchivos.add(archivos[i].toString()); System.out.println(arrayArchivos.get(i)); cajaFicheros.append(System.getProperty("line.separator")); cajaFicheros.append(arrayArchivos.get(i)); } cFtp.logout(); cFtp.disconnect(); System.out.println("Conexion Finalizada, buenas tardes."); } catch (IOException ioe) { System.out.println("error" + ioe.toString()); } } }); try { salir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } catch (Exception e) { } try { atras.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FormularioAccesoFtp accesoFtp = new FormularioAccesoFtp(); accesoFtp.inicioFtp(); principal.setVisible(false); } }); } catch (Exception e) { } }
From source file:uk.ac.liverpool.narrative.SolutionGraph.java
public void runStory(Template template, JTextArea out, JTextField in) throws NumberFormatException, IOException { if (template == null) return;/* w w w. j av a 2s . c om*/ out.append("Welcome to the interactive : " + solutions.get(0).domainName + " Story\n"); out.append("\n"); out.append("A story with " + solutions.size() + " paths and " + ends.size() + " endings\n\n\n"); STRIPSState current = start; mainLoop(template, out, in, current); }
From source file:uk.ac.liverpool.narrative.SolutionGraph.java
/** * @param template/* w w w . j a v a 2 s. c o m*/ * @param out * @param in * @param current * @return * @throws IOException */ private StringBuilder mainLoop(final Template template, final JTextArea out, final JTextField in, STRIPSState current) throws IOException { Collection<Action> aa = ggraph.getOutEdges(current); StringBuilder ssf = new StringBuilder(); if (aa == null) { out.append("No action from the start?\n"); return ssf; } do { if (aa.size() == 1) { Action a = aa.iterator().next(); out.append(actionToString(template, a)); ssf.append(actionToString(template, a)); if (a != null) { current = ggraph.getOpposite(current, a); } } else if (aa.size() > 1) { int n = 0; final Map<Integer, Action> hm = new MapWrapper<Integer, Action>(); out.append(" Please select the next action: " + "\n"); Iterator<Action> it = aa.iterator(); while (it.hasNext()) { n++; Action a = it.next(); out.append(" " + n + ") " + actionToString(template, a)); hm.put(n, a); } out.append("" + "\n"); final STRIPSState c2 = current; in.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) return; int a = 0; String s = in.getText(); try { a = Integer.parseInt(s); } catch (Exception x) { } try { a = Integer.parseInt(s); Action a2 = hm.get(a); if (a2 != null) { out.append(actionToString(template, a2)); in.removeKeyListener(this); in.setText(""); mainLoop(template, out, in, ggraph.getOpposite(c2, a2)); } } catch (Exception x) { return; } super.keyReleased(e); } }); return ssf; } else { break; } aa = ggraph.getOutEdges(current); } while (aa.size() > 0); out.append("The end"); return ssf; }
From source file:View.ReadView.java
public ReadView(ReadController controller, Email obj) throws IOException { this.frame = new JFrame(); this.topPane = new JPanel(); this.topLeftPane = new JPanel(); this.topRightPane = new JPanel(); this.topBottomPane = new JPanel(); this.container = frame.getContentPane(); this.controller = controller; this.bottomPane = new JPanel(); frame.setTitle("Ler Email"); container.setLayout(new BorderLayout(20, 20)); JButton btnSave = new JButton("Salvar no Banco"); btnSave.addActionListener((ActionEvent e) -> { try {//from ww w. j ava 2s.c om if (controller.save()) { JOptionPane.showMessageDialog(null, "Mensagem salva com sucesso"); } else { JOptionPane.showMessageDialog(null, "Erro ao salvar mensagem"); } } catch (ClassNotFoundException | SQLException | ParseException ex) { Logger.getLogger(ReadView.class.getName()).log(Level.SEVERE, null, ex); } }); JLabel labelAddress = new JLabel(); labelAddress.setText("Email: " + obj.getAddress()); JLabel labelDate = new JLabel(); labelDate.setText("Data: " + obj.getDate()); JLabel labelSubject = new JLabel(); labelSubject.setText("Assunto: " + obj.getSubject()); JTextArea message = new JTextArea(); message.append("Mensagem aqui..." + obj.getMessage()); messagePane = new JScrollPane(message); topPane.setLayout(new BorderLayout(20, 20)); topPane.add(BorderLayout.WEST, topLeftPane); topPane.add(BorderLayout.EAST, topRightPane); topPane.add(BorderLayout.SOUTH, topBottomPane); topLeftPane.setLayout(new FlowLayout(FlowLayout.LEFT)); topRightPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); topBottomPane.setLayout(new FlowLayout(FlowLayout.LEFT)); topLeftPane.add(labelAddress); topRightPane.add(labelDate); topBottomPane.add(labelSubject); bottomPane.add(btnSave); container.add(BorderLayout.NORTH, topPane); container.add(BorderLayout.CENTER, messagePane); container.add(BorderLayout.SOUTH, bottomPane); frame.pack(); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setSize(600, 600); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); frame.setVisible(true); }