Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  system to status window in applet  (Read 1116 times)
0 Members and 1 Guest are viewing this topic.
Offline straydoginc

Junior Member





« Posted 2005-08-10 19:52:35 »

is there a way to send the

System.out.println(); to a status window or a text area.. using

import javax.swing.JTextArea

Huh?
Offline cborders

Junior Member





« Reply #1 - Posted 2005-08-10 19:55:40 »

Instead of using System.out.println() you could just use JTextArea.append(), unless I am misunderstanding youe question.

CaseyB
Offline Jackal von ÖRF

Junior Member





« Reply #2 - Posted 2005-08-10 20:14:01 »

Is it possible to use System.setOut() in an applet?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2005-08-11 01:24:14 »

is there a way to send the

System.out.println(); to a status window or a text area.. using

import javax.swing.JTextArea

Huh?

No to my knowledge you cannot just point a stream at a text area.  You can redirect out to a differnt stream but you would have write your own stream type to
take the stramed input and draw it to a text window.

Most browsers however have a console you can turn on that will ctach all Java output if your just trying to see your errors.



Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline straydoginc

Junior Member





« Reply #4 - Posted 2005-08-11 14:49:19 »

Yup yup .. here is what I have

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.applet.Applet;
import javax.swing.JTextArea;

 in my main class

-----------
private JTextArea status   = null;
----------

then later on i have

---------------------
private void setupStatus( JTextArea ta ) {
      // Setup Status Area.
      setupStatus( status );

      // -------- JTextArea status --------
      if ( null == ta ) {
         status = new StatusArea( 5, 20 );
      }
      else {
         status = ta;
      }

      // JScrollPane pane = new JScrollPane();
      // pane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
      // );
      // pane.setHorizontalScrollBarPolicy(
      // JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
      //
      // pane.getViewport().add( status );
      // this.add( pane );
   }
---------------------

And then the seperate StatusArea Class

----------------

import java.awt.Color;
import javax.swing.JTextArea;
--------------------

then later on

------------------

public class StatusArea extends JTextArea {

   public StatusArea(int rows, int columns) {
      super( rows, columns );
      setBackground( new Color( 255, 255, 203 ) );
      setEditable( false );
      setLineWrap( true );
      setWrapStyleWord( true );
   }

   // Overwriting the default Append class such that it scrolls to the
   // bottom of the text. The JFC doesn't always rememeber to do that.
   public void append( String str ) {
      super.append( str );
      setCaretPosition( getText().length() );
   }
}


now i just need to be able to put my text in there.

Which i am having trouble doing
Offline cborders

Junior Member





« Reply #5 - Posted 2005-08-11 15:10:14 »

If I understand what you are trying to get at, then it should be like this:
1  
2  
3  
4  
5  
6  
7  
8  
try
{
    soemthing;
}
catch(SomeException e)
{
    status.append(e.toString());
}

or if at some point you would do a
1  
System.out.println(someIntVariable);

just change it to
1  
status.append(Integer.toString(someIntVariable));


CaseyB
Offline Jackal von ÖRF

Junior Member





« Reply #6 - Posted 2005-08-11 22:57:38 »

private void setupStatus( JTextArea ta ) {
      // Setup Status Area.
      setupStatus( status );

      // -------- JTextArea status --------
      if ( null == ta ) {
         status = new StatusArea( 5, 20 );
      }
      else {
         status = ta;
      }
   }
What's the point of that setupStatus( status ); method call in the beginning of setupStatus? Doesn't that just keep on calling setupStatus indefinitely (and cause a StackOverflowError)?

Offline straydoginc

Junior Member





« Reply #7 - Posted 2005-08-12 15:18:49 »

Well funny thing is that it actually did. This has since been removed as I relized this and was calling it further up in my code Smiley

The joys of learning Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (90 views)
2014-09-10 06:39:09

Tekkerue (44 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (48 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (37 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!