Java Code Examples for javax.swing.JTextArea.append()

The following are Jave code examples for showing how to use append() of the javax.swing.JTextArea class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: dead-code-detector   File: ParametersController.java   Source Code and License Vote up 6 votes
@SuppressWarnings("resource")
ParametersController(FileTable fileTable, JTextArea textArea, JProgressBar progressBar) {
	super();
	this.fileTable = fileTable;
	this.textArea = textArea;
	this.progressBar = progressBar;
	textArea.append(DeadCodeDetector.APPLICATION_NAME + '\n');
	try {
		System.setOut(new PrintStream(new TextAreaOutputStream(textArea), true, "UTF-8"));
	} catch (final UnsupportedEncodingException e) {
		// ne peut pas arriver
		throw new IllegalStateException(e);
	}
	fileChooser.setMultiSelectionEnabled(true);
	fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
}
 
Example 2
Project: Equella   File: ExceptionDialog.java   Source Code and License Vote up 6 votes
public void populateStackTrace(JTextArea view, Throwable t)
{
	view.append(t.toString() + '\n');

	StackTraceElement[] trace = t.getStackTrace();
	for( int i = 0; i < trace.length; i++ )
	{
		view.append("\tat " + trace[i] + '\n');
	}

	Throwable ourCause = t.getCause();
	if( ourCause != null )
	{
		populateStackTraceAsCause(view, ourCause, trace);
	}
}
 
Example 3
Project: spellchecker_ta   File: Utils.java   Source Code and License Vote up 6 votes
public static void printStack(Stack s,String title,JTextArea t)
{
	Stack s1 = (Stack)s.clone();
	String output = newLineStr + title + ":";
	while (!s1.empty())
	{
		Entry entry = (Entry)s1.pop();
		String str = TabConverter.revert(entry.getPart());
		output += (newLineStr + str);
		int tag = entry.getTag();
		if(tag != -1)
			str = " < " + analyser.Analyser.Tags.getString(String.valueOf(tag)) + " > ";
		else str = "";

		output += (str);
	}

	output += newLineStr + "---------------";
	t.append(output);
}
 
Example 4
Project: Install_Builder_Universal   File: GNULicenseWindow.java   Source Code and License Vote up 6 votes
private void initialize() {
	txtArea = new JTextArea();
	txtArea.setFont(new Font(Font.SANS_SERIF, 0, 12));
	txtArea.setEditable(false);
	JScrollPane sp = new JScrollPane(txtArea);
	sp.setBounds(5, 5, 600, 410);
	frame.getContentPane().add(sp);
	
	btnOk = new JButton("OK");
	btnOk.setFont(new Font(Font.SANS_SERIF, 0, 12));
	btnOk.setBounds(510, 420, 95, 20);
	btnOk.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			frame.dispose();
		}
	});
	frame.getContentPane().add(btnOk);
	
	txtArea.append(new Utils().getLicenseFile());
	txtArea.setCaretPosition(0);
}
 
Example 5
Project: oxygen-dita-translation-package-builder   File: TranslationPackageBuilderExtension.java   Source Code and License Vote up 5 votes
/**
 *  Shows a message dialog with the unpacked/overriden files.
 * 
 * @param pluginWorkspaceAccess  Entry point for accessing the DITA Maps area.
 * @param list  The relative paths of the unzipped files.
 * @throws IOException  Problems reading the files.
 */
private void showReport(final StandalonePluginWorkspace pluginWorkspaceAccess,
    ArrayList<String> list) throws IOException {
  final PluginResourceBundle resourceBundle = pluginWorkspaceAccess.getResourceBundle();

  // Present a log with the overridden files.
  if(list != null && !list.isEmpty()){
    JTextArea text = new JTextArea(10, 40);

    // Iterate with an index and put a new line
    //    for all lines except the first one. 
    text.append(list.get(0));
    for(int i = 1; i < list.size(); i++){
      text.append("\n");
      text.append(list.get(i));
    }
    text.setLineWrap(true);
    text.setWrapStyleWord(true);
    text.setEditable(false);

    JScrollPane scroll = new JScrollPane(text);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    JPanel panel = new JPanel(new GridBagLayout());

    GridBagConstraints gbcLabel = new GridBagConstraints();
    gbcLabel.gridx = 0;
    gbcLabel.gridy = 0;
    gbcLabel.gridwidth = 1;
    gbcLabel.gridheight = 1;
    gbcLabel.weightx = 0;
    gbcLabel.weighty = 0;
    gbcLabel.fill = GridBagConstraints.HORIZONTAL;
    gbcLabel.anchor = GridBagConstraints.NORTH;

    panel.add(new JLabel(resourceBundle.getMessage(Tags.SHOW_REPORT_LABEL)), gbcLabel);

    GridBagConstraints gbcScroll = new GridBagConstraints();
    gbcScroll.gridx = 0;
    gbcScroll.gridy = 1;
    gbcScroll.gridwidth = 1;
    gbcScroll.gridheight = 1;
    gbcScroll.weightx = 0;
    gbcScroll.weighty = 0;
    gbcScroll.fill = GridBagConstraints.BOTH;
    gbcScroll.anchor = GridBagConstraints.LINE_START;
    panel.add(scroll , gbcScroll);


    JOptionPane.showMessageDialog((JFrame) pluginWorkspaceAccess.getParentFrame(), panel, resourceBundle.getMessage(Tags.SHOW_REPORT_TITLE), JOptionPane.INFORMATION_MESSAGE);
  }
  else{
    throw new IOException(resourceBundle.getMessage(Tags.SHOW_REPORT_EXCEPTION_MESSAGE));
  }
}
 
Example 6
Project: Equella   File: ExceptionDialog.java   Source Code and License Vote up 5 votes
private void populateStackTraceAsCause(JTextArea view, Throwable t, StackTraceElement[] causedTrace)
{
	StackTraceElement[] trace = t.getStackTrace();
	int m = trace.length - 1;
	int n = causedTrace.length - 1;

	while( m >= 0 && n >= 0 && trace[m].equals(causedTrace[n]) )
	{
		m--;
		n--;
	}
	int framesInCommon = trace.length - 1 - m;

	view.append("Caused by: " + t.toString() + '\n');
	for( int i = 0; i <= m; i++ )
	{
		view.append("\tat " + trace[i] + '\n');
	}

	if( framesInCommon != 0 )
	{
		view.append("\t... " + framesInCommon + " more\n");
	}

	// Recurse if we have a cause
	Throwable ourCause = t.getCause();
	if( ourCause != null )
	{
		populateStackTraceAsCause(view, ourCause, trace);
	}
}
 
Example 7
Project: JITRAX   File: ErrorsDialog.java   Source Code and License Vote up 5 votes
public ErrorsDialog(ArrayList<String> errors) {
	okButton = new JButton("Ok");
	errorsTextArea = new JTextArea();
	
	setLayout(new BorderLayout());
	okButton.addActionListener(new OkButtonListener());
	errorsTextArea.setEditable(false);
	
	// Showing errors
	for (int i = 0; i < errors.size(); i++) {
		errorsTextArea.append(" - " + errors.get(i) + "\n");
	}
	
	JPanel mainContainer = new JPanel(new BorderLayout());
	JPanel messagePanel = new JPanel();
	JPanel buttonsPanel = new JPanel();
	messagePanel.add(new JLabel(MESSAGE));
	JScrollPane errorsPanelSP = new JScrollPane(errorsTextArea);
	errorsPanelSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	errorsPanelSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	
	mainContainer.setBorder(BorderFactory.createEmptyBorder(PADDING_TOP, 
			PADDING_LEFT, PADDING_BOTTOM, PADDING_RIGHT));
	
	buttonsPanel.add(okButton);
	mainContainer.add(messagePanel, BorderLayout.NORTH);
	mainContainer.add(errorsPanelSP, BorderLayout.CENTER);
	mainContainer.add(buttonsPanel, BorderLayout.SOUTH);
	
	add(mainContainer);
	buildWindow();
}
 
Example 8
Project: SE2Project   File: KundenDetailAnzeigerWerkzeug.java   Source Code and License Vote up 5 votes
/**
 * Setzt den Kunden, dessen Details angezeigt werden sollen.
 * 
 * @param kunde Ein Kunde, oder null um die Detailanzeige zu leeren.
 * 
 */
public void setKunde(Kunde kunde)
{
    JTextArea selectedKundenTextArea = _ui.getKundenAnzeigerTextArea();
    selectedKundenTextArea.setText("");
    if (kunde != null)
    {
        selectedKundenTextArea.append(kunde.getFormatiertenString());
    }
}
 
Example 9
Project: SE2Project   File: RueckgabeWerkzeug.java   Source Code and License Vote up 5 votes
/**
 * Zeigt die Details der ausgewählten Verleihkarten an.
 */
private void zeigeAusgewaehlteVerleihkarten()
{
    List<Verleihkarte> selektierteVerleihkarten = getSelectedVerleihkarten();
    JTextArea _ausgewaehlteVerleihkartenTextArea = _rueckgabeUI
        .getVerleihkartenAnzeigerTextArea();
    _ausgewaehlteVerleihkartenTextArea.setText("");
    for (Verleihkarte verleihkarte : selektierteVerleihkarten)
    {
        _ausgewaehlteVerleihkartenTextArea
            .append(verleihkarte.getFormatiertenString());
        _ausgewaehlteVerleihkartenTextArea.append("--------------- \n");
    }
}
 
Example 10
Project: MaxSim   File: ImportLogErrorDialog.java   Source Code and License Vote up 5 votes
public static void showDialog(Component parent, List<LogParser.ParseError> errors) {
    JTextArea txaErrors = new JTextArea();
    
    for (LogParser.ParseError error : errors) {
        txaErrors.append("Error at line " + error.getLineNumber());
        txaErrors.append(": " + error.getMessage());
        txaErrors.append("\n");
        txaErrors.append("Log line: " + error.getLine());
        txaErrors.append("\n");
    }
    
    JScrollPane scpErrors = new JScrollPane(txaErrors);
    
    JOptionPane.showMessageDialog(parent, scpErrors, "Parse errors", JOptionPane.ERROR_MESSAGE);
}
 
Example 11
Project: openvisualtraceroute   File: LicenseDialog.java   Source Code and License Vote up 5 votes
/**
 * Constructor
 */
public LicenseDialog(final Window parent) {
	super(parent, Resources.getLabel("license.button"), ModalityType.APPLICATION_MODAL);
	getContentPane().add(createHeaderPanel(false, null), BorderLayout.NORTH);
	final JTextArea license = new JTextArea(30, 50);
	license.setEditable(false);
	// read the license file and add its content to the JTextArea
	for (final String line : Util.readUTF8File(Resources.class.getResourceAsStream("/" + Resources.RESOURCE_PATH + "/License.txt"))) {
		license.append("   " + line + "\n");
	}
	// scroll to the top of the JTextArea
	license.setCaretPosition(0);
	// the all thing in a ScrollPane
	final JScrollPane scroll = new JScrollPane(license);
	getContentPane().add(scroll, BorderLayout.CENTER);
	final JPanel donatePanel = new JPanel(new BorderLayout(5, 10));
	final JLabel donate = new JLabel(Resources.getLabel("donate"));
	donatePanel.add(donate, BorderLayout.NORTH);
	final JPanel center = new JPanel();
	center.setLayout(new FlowLayout());
	center.add(new JLabel(Resources.getImageIcon("donate.png")));
	center.add(new HyperlinkLabel(Resources.getLabel("donate.label"), Env.INSTANCE.getDonateUrl()));
	donatePanel.add(center, BorderLayout.CENTER);
	final JButton close = new JButton(Resources.getLabel("close.button"));
	close.addActionListener(e -> LicenseDialog.this.dispose());
	donatePanel.add(close, BorderLayout.SOUTH);
	getContentPane().add(donatePanel, BorderLayout.SOUTH);
	SwingUtilities4.setUp(this);
	getRootPane().registerKeyboardAction(e -> dispose(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
 
Example 12
Project: geomapapp   File: ProjectionDialog.java   Source Code and License Vote up 5 votes
public void fileDetails(String[] fileAtt2){
	final String newline = "\n";
	JTextArea text = new JTextArea(15,100);
	text.setLineWrap(true);

	if(fileAtt2==null){
		String messageNan = "No file details available.\n";
		text.append(messageNan);
	} else {
	/* Goes through the attributes and prints each row on newline.
	 * If line contains extra quotes,tab,newline strips that out.
	 * Rules wont apply in a textarea.
	 */
	for(int p =0; p<fileAtt2.length; p++) {
		String attributeItem=fileAtt2[p];
		attributeItem=attributeItem.replace("\"", "");
		attributeItem=attributeItem.replace("\\t", "");
		if(attributeItem.contains("\\n")) {
			attributeItem=attributeItem.replace("\\n", "SC123");
			String[] itemsArray = attributeItem.split("SC123");
			String itemFormat = itemsArray[0];
			for(int q=1; q<itemsArray.length; q++) {
				itemFormat += " " + itemsArray[q];
			}
			attributeItem=itemFormat;
		}
		text.append(attributeItem + newline);
	}
}
	text.setEditable(false);
	JScrollPane scroll = new JScrollPane(text);
	scroll.setPreferredSize(new Dimension(350, 200));
	//JOptionPane.showMessageDialog(null, scroll); // with JTextArea
	JOptionPane.showMessageDialog(null, scroll, "File Details", JOptionPane.DEFAULT_OPTION);
}
 
Example 13
Project: geomapapp   File: MGGDataDisplay.java   Source Code and License Vote up 5 votes
public void readAsH77 (JTextArea text, File h77File) throws IOException {
	BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(h77File)));
	text.append( in.readLine() );
	String s;
	while( (s=in.readLine())!=null ) {
		text.append("\n"+s);
	}
	in.close();
}
 
Example 14
Project: geomapapp   File: MGGDataDisplay.java   Source Code and License Vote up 5 votes
public void readAsH77T (JTextArea text, File h77File) throws IOException {
	BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(h77File)));
	// read in each line and split into fields
	ArrayList<String[]> lines = new ArrayList<String[]>();
	String l;
	while( ( l=in.readLine())!=null ) {
		lines.add(l.split("\t"));
	}
	// if file has a header line, containing field names, use that, else use convention values
	// by convention we can detect this if the second field name is "FORMAT_77"
	if (!lines.get(0)[1].equals("FORMAT_77")) {
		lines.add(0,  CONVENTION_M77T_LABELS);
	}
				
	int numFields = lines.get(0).length;

	for (int i=0; i < numFields; i++) {

		for (int j=0; j<lines.size(); j++) {
			String[] line = lines.get(j);
			if (j == 0) {
				text.append(line[i] + ":\t");
			} else if (line.length > i) text.append(line[i] + "\t");
		}
		text.append("\n");
	}
	in.close();
}
 
Example 15
Project: JavaGraph   File: PrologDisplay.java   Source Code and License Vote up 4 votes
/**
 * Pretty print the results of the query in the output panel
 */
private void processResults(QueryResult queryResult) {
    try {
        getUserOutput().flush();
    } catch (IOException e) {
        // ignore
    }
    JTextArea results = getResultsArea();
    if (!results.getText().endsWith("\n")) {
        results.append("\n");
    }
    if (queryResult == null) {
        results.append("No\n");
        getNextResultAction().setEnabled(false);
    } else {
        switch (queryResult.getReturnValue()) {
        case SUCCESS:
        case SUCCESS_LAST:
            this.solutionCount++;
            for (Entry<String,Object> entry : queryResult.getVariables().entrySet()) {
                results.append(entry.getKey());
                results.append(" = ");
                if (entry.getValue() instanceof Term) {
                    results.append(TermWriter.toString((Term) entry.getValue()));
                } else {
                    results.append("" + entry.getValue());
                }
                results.append("\n");
            }
            results.append("Yes\n");
            getNextResultAction().setEnabled(true);
            break;
        case FAIL:
            results.append("No\n");
            getNextResultAction().setEnabled(false);
            break;
        case HALT:
            results.append("Interpreter was halted\n");
            break;
        default:
            results.append(String.format("Unexpected return value: %s",
                getEngine().lastReturnValue().toString()));
        }
        this.resultsStatus.setText(String.format("%d solution(s); Executed in %fms",
            this.solutionCount,
            queryResult.getExecutionTime() / 1000000.0));
    }
}
 
Example 16
Project: code-sentinel   File: ReplAgGUI.java   Source Code and License Vote up 4 votes
void initGui() {
    Font font = new Font("Courier", Font.PLAIN, 14);
    command = new JTextField(40);
    command.setFont(font);
    command.setToolTipText("Type a Jason operation here.");
    command.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            execCmd(command.getText().trim());
        }
    });

    //mindPanel = new JTextPane();
    //mindPanel.setEditable(false);
    //mindPanel.setContentType("text/html");
    
    output = new JTextArea(5,50);
    output.setFont(font);
    output.setEditable(false);
    output.setText("Example of operations you can type:\n   +bel; !goal; .add_plan({+!goal <- .print(ok) }); !!goal; \n   .send(bob,tell,hello);\n");
    output.append("   ?bel(A); .findall(X,bel(X),L); \n");
    output.append("   .mi // to open mind inspector\n");
    output.append("   .verbose(2) // to show debug messages\n");
    output.append("   .clear // clean console\n");
    output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console.");
    
    output.append("\n");
    

    frame = new JFrame(".::  REPL Interface for "+getTS().getUserAgArch().getAgName()+"  ::.");
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(BorderLayout.NORTH,command);    
    //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel));
    frame.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output));

    frame.pack();
    int h = 200;
    int w = (int)(h*2*1.618);
    frame.setBounds((int)(h*0.618), 20, w, h);
    frame.setLocation(lastPos, 200+lastPos);
    lastPos += 50;
    frame.setVisible(true);
}
 
Example 17
Project: Recaf   File: SwingUI.java   Source Code and License Vote up 3 votes
/**
 * Creates a new tab with the given text.
 * 
 * @param title
 *            Title of tab.
 * @param content
 *            Content of tab.
 */
public void openMessage(String title, String content) {
	JTextArea text = new JTextArea();
	text.setEditable(false);
	text.append(content);
	openTab(title, new JScrollPane(text));
}