Writing console output from numerous classes to JTextArea?

I have written a GUI for several classs and I was wondering if it is possible to have the output from these classes written to something like a JTextArea or equivalent.
I know I could store the output (instead of System.out.print) and then setup a JTextArea and set the text equal to the stored output. I was hoping there was another way to do this that'd be more aesthetic.
Thanks in advance.
Se�n

I have written a GUI for several classs and I was
wondering if it is possible to have the output from
these classes written to something like a JTextArea
or equivalent.
I know I could store the output (instead of
System.out.print) and then setup a JTextArea and set
the text equal to the stored output. I was hoping
there was another way to do this that'd be more
aesthetic.
java.util.logging?Alternatively, create a TextAreaPrintStream class, overriding the appropriate methods and then call
System.setOut(someTextAreaPrintStream);Jim S.

Similar Messages

  • Output from java class and display

    I have a big output from a java class after executing a java class... where can store that huge output before I <cflocation to the same page? I need to display the output to the user on the relocated page...Any help appreciated...

    cfsavecontent to a session variable.

  • Create console output from LabView

    Hi all.
    Is there any way of creating a console string output when calling a dll from LabView?
    I have to call a C++ program from LabView and I'm using a dll. I need to debug this program, and I think that using "cout" is the fastest and simplest way.
    Thanks in advance.
    Regards,
    Francisco

    No, there is no console output when calling a DLL. You could have your DLL simply write debug information to a log file.

  • Append output from other class

    Hello!
    I have a blackjack game where I have used a.append(); to send output to a graphic textarea instead of the console.
    My game consists of several classes where one of them is the one who runs the actual game with graphic things and so on.
    In this class the a.append works fine since the textarea is in that class.
    But how shall I do to append output in other classes? If I try to compile I get the error message "Error resolving symbol" since the other class does not recognize the graphical textarea a.
    How do I make the other classes to recognize the graphical object?
    Thanks very much!

    This is the computer class:
    import javax.swing.*;
    public class Dator extends Spelare {
    private Spelare motspelare;
    public Dator(Kortbunt k, Spelare mot){
    super(k);
    motspelare = mot;
    public void spela() {
    nyttSpel();
    while (p < 21 && p < motspelare.po�ng()) {
    a.append("Datorn fick " + nyttKort() + "\n");
    a.append("Datorn har " + p + " po�ng.\n");
    The a.append only works in the class where the graphical object lies. I want this class to recognize the graphic object in the other class so that it understands the append code.

  • Get output from dos window to jtextarea/textarea

    hi
    i am executing the following lines of code:
    1)Runtime r=Runtime.getRuntime();
    Process p=r.exec("javac <filename.java>");
    when executing this there is no exception fired but i am not being able
    to get the output from the ods console to a textarea
    or for that matter i donot get any output anywhere
    2)if i change it to
    Process p=r.exec("java <filename");
    similar thing happens i.e no output
    can anyone plz help
    thanx.

    Sorry, this < was the wong way around
    Process p=r.exec("java filename >test.txt")
    Then read in data from test.txt, something like this should do it :))   public String getTextFile(String text) throws Exception{
          int reader = 0;
          text = "";
          FileReader in = new FileReader("test.txt");
             do {
                reader = in.read();
                text += (char)reader;
             }  while (reader != -1);
          in.close();
          return text;

  • Where do I find output from verbose:class?

    I want to find out where a class is being loaded from. So, using the config tool, I have added "-verbose:class" to the server's Java parameters and restarted. However, I cannot find the logging file that contains the expected output from enabling this option. What file do I look in? It's not in server0/log/defaultTrace.trc nor server0/kernel/classload/default.trc.

    hi,
    the following link gives u the details about the usage of verbose:class.. its an extract from a book..
    it opens only if you a g-mail account.. if u don have i can send u an invite
    http://books.google.co.in/books?ie=UTF-8&hl=en&vid=ISBN0201753065&id=CvvdZtzxnAEC&dq=outputfromverboseclass&vq=outputfromverboseclass&prev=http://books.google.co.in/books%3Fq%3Doutput%2Bfrom%2Bverbose%2Bclass&lpg=PA45&pg=PA45&sig=SV45ZjMHXGi87y0GR7CLOOFA3_w
    hope it might help you,
    naveen

  • Analogue Output from Numeric Value

    I have a VI which converts a digital signal into a speed based on the number of pulses per revolution. What I would like to do is now output that numeric value as a scaled 0-5V channel. I have tried to use the DAQassistant as with all of my other analogue outputs but it gives a buffer error. I know it can't be that hard to implement, can someone point me in the right direction...
    Thanks,
    Richard

    Thanks
    Files are attached save under version 11.0/
    Attachments:
    MeasureFreqandGraphSpeed.vi ‏13 KB
    ObtainSpeed.vi ‏23 KB

  • How to see "console output" from the java web start ?

    Hi all.
    I wish to see logging infomation from the client side when using java web start technologie (java1.6 version).
    Please help.
    Thak's

    Use the "Advanced" tab of the Java Control Panel to turn on "tracing" and/or the Java Console.
    see:
    http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/troubleshooting.03.06.html
    /Andy

  • Get output from dos window to jtextarea

    the code is:
    Runtime r=Runtime.getRuntime();
    Process p=r.exec("javac <filename>");
    i have used
    BufferedReder br=new BufferedReader(new InputStreamReader(p.getOutputStream));
    but on compilation it shows error
    plz someone help
    i need it urgently.

    Sorry, this < was the wong way around
    Process p=r.exec("java filename >test.txt")
    Then read in data from test.txt, something like this should do it :))   public String getTextFile(String text) throws Exception{
          int reader = 0;
          text = "";
          FileReader in = new FileReader("test.txt");
             do {
                reader = in.read();
                text += (char)reader;
             }  while (reader != -1);
          in.close();
          return text;

  • Writing and outputing from txt file

    Hello guys,
    Can you guys show me where I can find the source of learning how to writing and getting the data that I input to the text file?
    Thanks.

    The java tutorial of course!
    http://java.sun.com/docs/books/tutorial/index.html
    The section about I/O is:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • How can I update a JTextArea from another class

    I am new to Java so forgive me if this is confusing, or if I seem to be taking an overly complex route to acheiving my goal.
    I've got a JTextArea component added to a JPanel object, which is then inserted into the JFrame. I have a JMenuBar with a JMenu "file" and a JMenuItem "connect" on this same JFrame. When clicked, the actionEvent of JMenuItem "connect" calls a class "ConnectToDb" to establish a connection with the Database. On a successful connection, I want to append the String "Connection Successful" to the JTextArea component, but since the component is a part of the JPanel object, I cannot seem to get access to the JTextArea component to update it. I tried instantiating the JPanel object from within the "ConnectToDb" class and then called a method I created to set the JTextArea. No luck. Can someone give me an idea of what I need to do that would allow me to update the text of the JTextArea component from anywhere in my program? Once it has been contained in the JPanel or JFrame, can it be updated?
    This is the class that establishes the simple Db Connection
    package cjt;
    import java.io.*;
    import java.sql.*;
    * Get a database connection
    * Creation date: (04/01/2002 4:08:39 PM)
    * @author: Yaffin
    public class ConnectToDB {
    public Connection dbConnection;
    // ConnectToDB constructor
    public ConnectToDB() {
    public Connection DbConnect() {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = new String("jdbc:odbc:CJTSQL");
    Connection dbConnection = DriverManager.getConnection(sourceURL, "Encryptedtest", "pass");
    System.out.println("Connection Successful\n");
    //this is where I originally tried to append "Connection Successful
    //to the JTextArea Object in WelcomePane()          
    } catch (ClassNotFoundException cnfe) {
    //user code
    System.out.println("This ain't working because of a class not found exeption/n");
    } catch (SQLException sqle) {
    //user code
    System.out.println("SQL Exception caused your DB Connection to SUCK!/n");
    return dbConnection;
    This is the JPanel that contains the JTextArea "ivjStatusArea" I am trying to update from other classes. Specifically the "ConnectToDb" class above.
    package cjt;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    * Build Welcome Pane
    * Creation date: (04/01/2002 3:42:50 PM)
    * @author: yaffin
    public class WelcomePane extends JPanel {
         private JTextArea ivjtxtConnect = null;
         private JLabel ivjwelcomeLbl = null;
         private JTextArea ivjStatusArea = null;
    * WelcomePane constructor comment.
    public WelcomePane() {
         super();
         initialize();
    * Return the StatusArea property value.
    * @return javax.swing.JTextArea
    private javax.swing.JTextArea getStatusArea() {
         if (ivjStatusArea == null) {
              try {
                   ivjStatusArea = new javax.swing.JTextArea();
                   ivjStatusArea.setName("StatusArea");
                   ivjStatusArea.setLineWrap(true);
                   ivjStatusArea.setWrapStyleWord(true);
                   ivjStatusArea.setBounds(15, 153, 482, 120);
                   ivjStatusArea.setEditable(false);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjStatusArea;
    * Initialize the class.
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("WelcomePane");
              setLayout(null);
              setSize(514, 323);
              add(getStatusArea(), getStatusArea().getName());
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    This is the main class where evrything is brought together. Notice the BuildMenu() method where the JMenuItem "connect" is located. Also notice the PopulateTabbedPane() method where WelcomePane() is first instantiated.
    * The main application window
    * Creation date: (04/01/2002 1:31:20 PM)
    * @author: Yaffin
    public class CjtApp extends JFrame {
    private JTabbedPane tabbedPane;
    private ConnectToDB cdb;
    private Connection dbconn;
    public CjtApp() {
    super("CJT Allocation Application");
    // Closes from title bar
    //and from menu
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    tabbedPane = new JTabbedPane(SwingConstants.TOP);
    tabbedPane.setForeground(Color.white);
    //add menubar to frame
    buildMenu();
    //populate and add the tabbed pane
    populateTabbedPane(dbconn);
    //tabbedPane.setEnabledAt(1, false);
    //tabbedPane.setEnabledAt(2, false);
    getContentPane().add(tabbedPane);
    pack();
    * Build menu bar and menus
    * Creation date: (04/01/2002 2:42:54 PM)
    private void buildMenu() {
    // Instantiates JMenuBar, JMenu,
    // and JMenuItem.
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item1 = new JMenuItem("Connect");
    JMenuItem item2 = new JMenuItem("Exit");
    //Opens database connection screen
    item1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    //call the ConnectToDb class for a database connection
    ConnectToDB cdb = new ConnectToDB();
    dbconn = cdb.DbConnect();
    }); // Ends buildMenu method
    //Closes the application from the Exit
    //menu item.
    item2.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    }); // Ends buildMenu method
    //Adds the item to the menu object
    menu.add(item1);
    menu.add(item2);
    //Adds the menu object with item
    //onto the menu bar     
    menubar.add(menu);
    //Sets the menu bar in the frame
    setJMenuBar(menubar);
    } //closes buildMenu
    public static void main(String[] args) {
    CjtApp mainWindow = new CjtApp();
    mainWindow.setSize(640, 480);
    mainWindow.setBackground(Color.white);
    mainWindow.setVisible(true);
    mainWindow.setLocation(25, 25);
    * Add tabs to the tabbedPane.
    * Creation date: (04/01/2002 2:52:19 PM)
    private void populateTabbedPane(Connection dbconn) {
         Connection dbc = dbconn;
         tabbedPane.addTab(
         "Welcome",
    null,
    new WelcomePane(),
    "Welcome to CJT Allocation Application");
         tabbedPane.addTab(
         "Processing",
    null,
    new ProcessPane(dbc),
    "Click here to process an allocation");
         tabbedPane.addTab(
         "Reporting",
    null,
    new ReportPane(),
    "Click here for reports");
    //End
    Thanks for any assistance you can provide.
    Yaffin

    Thanks gmaurice1. I appreciate the response. I believe I understand your explanation. I am clear that the calling code needs access to the WelcomPane() object. I am assuming that the constructor for the calling class must have the JPanel WelcomePane() instance passed to it as an argument. This way I can refer directly to this specific instance of the object. Is this correct?
    Also, where would you create the set method? I tried to create a set method as part of the WelcomePane() class, and then call it from the calling class, but it didn't seem to work. Lastly, a globally accessible object? Can you explain this concept briefly? Thanks again for your help.
    yaffin

  • Can anyone help me understand this output from Console?

    My Macbook Pro freezes and I have to manually shut it down and restart it.  This is the error output from Console after I restart the Mac and find the time that the Mac froze.
    Here is the error code again, if it was too hard to read from the image above:

    Hi, did you find any answer to this? I have the same problem with globeinvestor.com gold tracker program. It stops to run from very beginning and give me a 23 code error.
    Their supprot can not fix this. Actually i have tried this in three different computers and all of them are same.

  • Sample Clock from Numerical Position Output of Digital Encoder

    Hey everyone,
    I'm trying to sample a voltage (pressure inside an engine) with my NI USB-6212 against a rotary encoder position (crankshaft angle). For some brief background, I'm using a producer/consumer structure and my rotary encoder has proprietary VIs from the manufacture to interface. It's from US Digital and it's an HD25A. It makes the most sense to use my rotary encoder as a sample clock so I wind up with a sampled point of pressure data for each crankshaft angle. This makes it far easier to average pressure traces together and work with the data.
    I've found quite a few threads on this (links at the end of my post) but they all rely on having a pulse output from the digital encoder which is then wired into a counter input on their board. I don't have a pulse output, my encoder is outputting a numeric value between 0 and my chosen resolution (currently 3600, so 0 to 3599).
    My question is how can I take this changing numerical output and make a sample clock pulse for each time the value changes? Does this need to be turned into a task to use as a sample clock? I'm essentially using the data acquistion program from the example program Cont Acq&Graph Voltage-Ext Clk.vi.
    Thanks in advance for any help you can lend me and my apologies if I missed a prior thread on this topic. My search-fu wasn't able to turn anything up.
    Some relevant links I found, though I couldn't quite make enough sense of them to get the fog to lift:
    http://forums.ni.com/t5/Counter-Timer/How-to-reset-a-counter-on-external-signal-in-LabView/td-p/1521...
    https://decibel.ni.com/content/docs/DOC-12106
    http://ni.lithium.com/t5/Multifunction-DAQ/Rotary-encoder-data-acquired-simultaneously-with-analog-i...

    I don't think there is anyway you are going to make this work like you think you can.  The US digital encoders I have worked with and their VI's were based on reading the current encoder count through a serial port connection.  To do what you want, you are going to need to read the encoder every time the count changes.  At 216 kHz, a serial connection is not going to be able to do that.  Even if it could, you would essentially still have some latency between when the count changed and when the VI would be able to request a reading and get a response that showed the count had changed.
    You need to use an encoder that has a digital pulse output that you could use as a sample clock on a data acquisition card.

  • JTextarea from Different Class

    Hello, I have been searching through the forums for a while and cannot find a suitable answer.
    I have a main class that has a JTextArea which logs all the actions of the program, lets call it main. One of the actions that 'main' performs is to launch a seperate class called 'AdvancedMode' which inherits everything from 'main'. So 'Advanced mode' has its own seperate log in a JTextArea also, and what I want to do is to append the text from 'Advanced Mode's JTextArea to 'Mains's JTextArea when the exit button is clicked.
    I have tried several methods including a timer that appends it every 20 seconds but that doesnt work because it just repeats the text, also I tried making a class in 'Main' that is called when 'Advanced Mode' exits but I get a null pointer excpetion because 'main' is created in ActionPerformed.
    Has anyone got a simple solution to this (probably) simple question as it is driving me up the wall.
    I was going to post some code, but I doubt you need it
    Thanks in advance.

    Ok, doubt it will help but here goes
    This is from the 'Main' Class, when the Advanced Mode button is hit a new instance of it is created
            if(e.getActionCommand() == "Advanced Mode") {
                tt = new AdvancedMode();
                tt.init();
                tt.setVisible(true);
                textArea.append("Advanced Mode Accessed at " + te.easyDateFormat("HH:mm")+nl);
                check(tt);
            }...and this is where the 'Advanced Mode's JTextArea is declared and created
            //Creates the log for the MySql Command results
            area = new JTextArea();
            area.setEnabled(false);
            area.setDisabledTextColor(Color.BLUE);
            area.append("***************************" +nl);
            area.append("Log of SQL Commands and Errors" +nl);
            area.append("***************************" +nl);
            JScrollPane scrollPane = new JScrollPane(area);
            scrollPane.setBorder(BorderFactory.createTitledBorder(scrollPane.getBorder(),"MySQL Log",2,2,null,Color.BLUE));
            scrollPane.setPreferredSize(new Dimension(50, 100));...and here is where the 'AdvancedMode' class deals with exiting
            if(e.getActionCommand() == "Exit") {
                // Modal dialog with yes/no button
                String message = "Are you sure you wish to exit advanced mode?";
                int answer = JOptionPane.showConfirmDialog(frame, message);
                if (answer == JOptionPane.YES_OPTION) {
                        //check();
                    dispose();
                } else if (answer == JOptionPane.NO_OPTION || answer == JOptionPane.CANCEL_OPTION) {
                    // User clicked NO.
            }I want to append 'Main's' JTextArea with the contents of 'AdvancedMode's' JTextArea when the exit button is hit

  • Keyboard input or Console Output

    I'm self teaching java... I got stuck with one of the exercises that is supposed to demonstrate the basic input and output through entering data on console...
    I went about writing the code as:
    public class Program2 {
    public static void main(final String [ ] args) {
    KeyboardInput in = new KeyboardInput () ;
    System.out.print ("Type your name: ") ;
    It doesn't compile:((((.... it says "KeyboardInput" is not a type...
    I would really appreciate if somebody could respond to this silly problem.

    For keyboard input from console the program would be
    public class Console{
      public static void main(String[] args){
        try{
          BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
          System.out.print("Enter Your Name: ");
          String name = reader.readLine();
          System.out.println("Your Name is "+name);
        }catch(Exception ex){
          ex.printStackTrace();
    }

Maybe you are looking for