DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004

    repainting graphics in application

    ive made a little hangman game that displays a string of text and some other stuff in the MSDOS window; now i want to make it graphical...I already have the graphics made, but ive run into a problem on how to update the graphics with the new data it gets everytime a user guesses a letter. My game consists of some static methods (I get errors if it is not static) that returns some stuff to be displayed. How do put graphics in my application??? thank you. basically here is a simplified version of the code:

    public static char GetLetter() {
    //does stuff
    return letter;

    public static String SearchingWord(whole buncha stuff) {
    //does stuff
    return worddisplay <--the String that i want to display
    public static void main(String[] args) {
    //does stuff

  2. #2
    Join Date
    Feb 2004
    youre getting errors when you remove the static references because you havent made any INSTANCES of classes... you need to read up on Object Oriented programming a little more, i think..

    however, you can probably hammer your existing code into a gui, but it wont be that easy..

    I suggest you look at the "drawString" method of the Graphics context, then assess how to override the paint() method of a JPanel in order to draw your graphics..

    however, you will run into serious problems and much confusion if you dont work out what object oriented programming is about (static is "bad" if you dont know about it.. making everything static is not a solution.. in any typical java program there is only one thing that is static; the main() method of the class that starts the ball rolling.

    if you cant remove the "static" references from your program and get it working in an object based fashion, youre not ready to move to drawing a gui (sounds harsh, but its true)
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.