Clearing Screens

I'm back again and I would now like to know how to clear a screen between prompts. Simple and strait forward. Thanks for the help.

Switalla

Comments

  • If it's a text example JText Area you can use this;
    [code]
    JTextArea jta ;
    jta.setText("");
    [/code]

    If it's a graphics use this code example;
    [code]
    // Buffered Graphics
    Dimension offDimension;
    Image offImage;
    Graphics offGraphics;

    void paint()
    {
    // Get the Graphics of the screen and the size
    Graphics g = getGraphics();
    Dimension d = size();

    // Create the offscreen graphics context, if no good one exists
    if (offGraphics == null || d.width != offDimension.width || d.height != offDimension.height)
    {
    offDimension = d;
    offImage = createImage(d.width,d.height);
    offGraphics = offImage.getGraphics();
    }

    //Clear screen
    offGraphics.setColor(Color.lightGray);
    offGraphics.fillRect(0,0,d.width,d.height);

    // Draw game objects
    offGraphics.setFont(font);
    offGraphics.setColor(Color.black);
    offGraphics.drawString("" + ball.scoreLeft,20,d.height-2);
    offGraphics.drawString("" + ball.scoreRight,d.width - 32,d.height-2);
    p1.paint(offGraphics);
    p2.paint(offGraphics);
    ball.paint(offGraphics);

    // Copy the off screen buffer to the screen.
    g.drawImage(offImage, 0, 0 , this);
    }
    [/code]

    If you need a full code example of the graphics I can mail
    that to you.

    bashiro

    : I'm back again and I would now like to know how to clear a screen between prompts. Simple and strait forward. Thanks for the help.
    :
    : Switalla
    :

  • OK. Is JTextArea part of Java or does it have to be imported. And if it does where am I able to get the files needed to be imported. ALSO. Just pasting this code:

    [code]
    JTextArea jta ;
    jta.setText("");
    [/code]

    into my code will make the screen clear? I understand that its making jta of type JTextArea but I'm not understanding what jta.setText(""); does except decalre it null. Maybe I'm missing something.

    Switalla
  • : OK. Is JTextArea part of Java or does it have to be imported. And if it does where am I able to get the files needed to be imported. ALSO. Just pasting this code:
    :
    : [code]
    : JTextArea jta ;
    : jta.setText("");
    : [/code]
    :
    : into my code will make the screen clear? I understand that its making jta of type JTextArea but I'm not understanding what jta.setText(""); does except decalre it null. Maybe I'm missing something.
    :
    : Switalla
    :

    I think you are missing the point completly. The code above does not clear your screen, its a TextArea used in GUI's (just like the text areas used in html to post a message on this board). The only thing this method does is clearing a TextArea.

    I think you want to know how to clear your command prompt window from your application, but i'm sorry to say i don't know that. Anyone?

    dvrslype
  • [b][red]This message was edited by bashiro at 2003-2-6 14:56:1[/red][/b][hr]
    Did you read the sentence I stated before I suggested that code ?
    If not re-read it.
    I said
    [red]
    If it's a text example JText Area you can use this;
    [/red]
    [code]
    JTextArea jta ;
    jta.setText("");
    [/code]
    [red]
    If it's a graphics use this code example;
    [/red]
    .........
    [green]
    You know a text area can be part of your screen. Likewise does
    a graphic area be part of your screen. So let Switalla elaborate what
    he wants.

    bashiro
    [/green]


    : : OK. Is JTextArea part of Java or does it have to be imported. And if it does where am I able to get the files needed to be imported. ALSO. Just pasting this code:
    : :
    : : [code]
    : : JTextArea jta ;
    : : jta.setText("");
    : : [/code]
    : :
    : : into my code will make the screen clear? I understand that its making jta of type JTextArea but I'm not understanding what jta.setText(""); does except decalre it null. Maybe I'm missing something.
    : :
    : : Switalla
    : :
    :
    : I think you are missing the point completly. The code above does not clear your screen, its a TextArea used in GUI's (just like the text areas used in html to post a message on this board). The only thing this method does is clearing a TextArea.
    :
    : I think you want to know how to clear your command prompt window from your application, but i'm sorry to say i don't know that. Anyone?
    :
    : dvrslype
    :



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories