Results 1 to 2 of 2

Thread: Writing text?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Talking Writing text?

    Newbie! hehe.
    I downloaded JBuilder 4. Then I went and I made a default aplet.
    It came up with this Java code.

    Code:
    package untitled1;
    
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    
    /**
     * Title:        fdvdfs
     * Description:  df
     * Copyright:    Copyright (c) 2001
     * Company:      ds
     * @author dsf
     * @version 1.0
     */
    
    public class Applet1 extends JApplet {
      boolean isStandalone = false;
      /**Get a parameter value*/
      public String getParameter(String key, String def) {
        return isStandalone ? System.getProperty(key, def) :
          (getParameter(key) != null ? getParameter(key) : def);
      }
    
      /**Construct the applet*/
      public Applet1() {
      }
      /**Initialize the applet*/
      public void init() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      /**Component initialization*/
      private void jbInit() throws Exception {
        this.setSize(new Dimension(400,300));
      }
      /**Start the applet*/
      public void start() {
      }
      /**Stop the applet*/
      public void stop() {
      }
      /**Destroy the applet*/
      public void destroy() {
      }
      /**Get Applet information*/
      public String getAppletInfo() {
        return "Applet Information";
      }
      /**Get parameter info*/
      public String[][] getParameterInfo() {
        return null;
      }
    
      //static initializer for setting look & feel
      static {
        try {
          //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }
        catch(Exception e) {
        }
      }
    }
    So then I decided I wanted to write something on the main screen.
    I tried this:

    Code:
      public void start() {
        System.out.println("HI there!");
      }
    That DID NOT WORK!!
    Can someone tell me how to write text on it?

  2. #2
    Lively Member moonguy's Avatar
    Join Date
    Apr 2001
    Location
    pune(india)
    Posts
    67

    oh no

    the System.out.println() statement prints a line of string to the standard output ie generally the console .To print a string on the applet u need to use the drawString method of the Graphics class.
    u use it like this. In your class add this method:

    public void paint(Graphics g)
    {
    g.drawString("string",xloc,yloc);
    }
    Vishal Mungi
    [email protected]
    www.geocities.com/vishalmungi

    VB,ASP,C++,Java,Oracle,MAX,photoshop,XML..,


    ~~~~
    \ - - /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width