DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  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.

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links