Simple question I DON'T know the answer to


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Simple question I DON'T know the answer to

  1. #1
    Join Date
    Oct 2002
    Posts
    3

    Question Simple question I DON'T know the answer to

    Hello everyone. This is my first post also my first question. I just started using Java about three months ago. So far I've really only done the basics. Still trying to learn it. Anyway, on with the question.

    For my java class I have built a simple program to genreate a random number and then display the number. NOW I am charged with the task of building a GUI interface for this small program. I have already built the interface but I cannot for the life of me figure out the syntax involved in calling my custom number class and displaying the result on a canvas in my GUI program.

    Any help is GREATLY appreciated.

  2. #2
    Join Date
    Sep 2002
    Posts
    124
    Hi, Myth. Welcome !

    Could you be a bit more specific as to how you want to display the random number ? If your GUI has a TextField or JTextField, Label or JLabel you can easily display it there. Or were you looking at an alert-type of display ?

    Joyous Monkey

  3. #3
    Join Date
    Oct 2002
    Posts
    3
    The GUI interface contains a canvas. I was trying to display the output of the RandomNumber.Class ON the canvas itself. Is that even possible?

  4. #4
    Join Date
    Sep 2002
    Posts
    78
    you might be able to write it with this (not sure if it works)

    drawString("Number: " + varName , x, y);

    though a text field would be better
    ¿Red Baron?
    [code] /* dont forget code tags! */ [/code]
    Come visit the Café!

  5. #5
    Join Date
    Sep 2002
    Posts
    124
    Here's Sun's own page dealing with Canvas

    http://java.sun.com/products/jdk/1.1...wt.Canvas.html

    Hope it helps

    JM

  6. #6
    Join Date
    Oct 2002
    Posts
    3
    Thank you for the replies guys. From reading your posts I got the idea to use a text field instead of the canvas and now it works. It seems that its a LOT easier to use the text field than the canvas. Anyway Thanks again guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center