Source codes and jframes

Hello ,
I am trying to make it so that I can somehow place this source code,
*Hi_LoGame.java*
Peter Hadlaw
*2009/10/12*
*This is a simple guessing game that tells the user if they got the number right or if the are too low or too high, and then asks if they wish to continue. It then prints the results, and the best score.*
import java.util.*;
public class Hi_LoGame {
    public static void main(String[] args) {
       Scanner userInput = new Scanner (System.in);
       int userC, userG=0, bestGNum=0, currentGNum=0, gamesP = 0, gNum = 0, cpuNum;
       Random cpuRandNumGen = new Random();
       System.out.println("Welcome to the Hi - Lo game showdown!!!\nWould you like to play: (1)Yes or (2)No?");
       userC = userInput.nextInt();
       while(userC<=0||userC>=3){
            System.out.println("Please enter a valid choice of 1 or 2.");
            userC = userInput.nextInt();
       cpuNum = cpuRandNumGen.nextInt(100)+1;+
+       while(userC==1){+
+                 currentGNum++;
                 System.out.print("Please enter a number from 1-100 for you guess: ");
                 userG=userInput.nextInt();
                 while(userG<=0||userG>100){
                      System.out.println("Please enter a valid guess:");
                      userG = userInput.nextInt();
                 if(userG==cpuNum){
                      System.out.println("Congradulations you got it right!");
                      System.out.println("You got it right in "  +currentGNum+  " guesses.");
                      System.out.println("Do you want to play (1)again or do you want to (2)stop");
                      userC = userInput.nextInt();
                      while(userC<=0||userC>=3){
                           System.out.println("Please enter a valid choice of 1 or 2.");
                           userC = userInput.nextInt();
                      if(gamesP==0)
                           bestGNum = currentGNum;
                      if(gamesP>1&&currentGNum<bestGNum){
                           bestGNum = currentGNum;
                      else{//nothing
                      gamesP++;
                      cpuNum = cpuRandNumGen.nextInt(100)+1;+
+                      if(userC==1){+
+                           currentGNum=0;+
+                      }+
+                      else{+
+                      }+
+                 }+
+                else if(userG>cpuNum){+
+                     System.out.println("Sorry but you are to high!");+
+                     System.out.println("Do you want to guess (1)again or do you want to (2)give up");+
+                      userC = userInput.nextInt();+
+                      while(userC<=0||userC>=3){+
+                           System.out.println("Please enter a valid choice of 1 or 2.");+
+                           userC = userInput.nextInt();+
+                      }+
+                      if(userC==2){+
+                           gamesP++;
                           System.out.println("You gave up ,your guess count was: "  +currentGNum);+
+                      }+
+                      else{+
+                      }+
+                }+
+                else{+
+                     System.out.println("Sorry but you are too low!");+
+                     System.out.println("Do you want to guess (1)again or do you want to (2)give up");+
+                      userC = userInput.nextInt();+
+                      while(userC<=0||userC>=3){+
+                           System.out.println("Please enter a valid choice of 1 or 2.");+
+                           userC = userInput.nextInt();+
+                      }+
+                      if(userC==2){+
+                           gamesP++;
                           System.out.println("You gave up ,your guess count was: "  +currentGNum);+
+                      }+
+                      else{+
+                      }+
+                }+
+       }+
+       if(gamesP==0){+
+            System.out.println("Thanks anyways, please come again.");+
+       }+
+       else{+
+            System.out.println("Thanks for playing, you last score is: "+  currentGNum  +" but your best guess number was in "+  bestGNum + " guesses.");
}into a jframe, I heard something about text panes or textareas maybe being able to print this, but i just want one simple jframe with the above, and the user can input stuff right then and their.
Thank You

What you currently have is a non-OOP class, one that is nothing but a big main method without methods, constructors, etc.
If this is your code, it suggests that you still have a bit to learn before tackling Java GUI such as writing classes, methods, constructors, etc. I mean feel free to read up on how to create a Swing GUI here [http://java.sun.com/docs/books/tutorial/uiswing/index.html] and jump right in, but just be forewarned that if you're jumping too early, it'll be a frustrating swim. Much luck.

Similar Messages

  • How to get source code and build files for Eudora 7, and price?

    Looking for source code and build/make files for Eudora 7 to port to Win7 and Ubuntu 14. Where is a source for this and what is the cost?

    You best ask qualcomm. It is their intellectual property.
    Eudora OSE was based on Thunderbird and the source code for the Penelope add-on is open source (that is what made Thunderbird over to OSE)

  • Finding source codes and page rankings

    I have just got the new upgraded Firefox, and I would like to know how to find two things in this browser:
    (1) the source codes for any site I visit, and
    (2) the page rankings for any site I visit,
    Or aren't these available on Firefox?
    Roger

    @pkgrace, what happens when you try to view source -- no window, blank window??
    It's possible to change the source viewer in preferences, so if you have been running Firefox for a while, it might be worth checking that.
    (1) Type or paste '''about:config''' in the address bar and press Enter (click the button promising to be careful, and please do be careful!)
    (2) In the filter box, type or paste '''view_''' and pause until the preferences are filtered
    (3) If '''view_source.editor.external''' appears bold (set to true), double-click it to reset it to false. You're done, you can close about:config now.
    If that isn't it, perhaps it's related to an add-on?? Please start a new question and use the feature to include a list of add-ons and customized settings with your question.

  • Best way to print source code and relationsh​ips

    I am the IT director for a medical technology company - we use Labview for our proprietary software.
    We have need to print all of our VIs, source code/block diagrams and the relationships between the modules. I know how to do this and the options which are available (for complete documentation, using as a sub vi, etc).
     I have found that printing to PDF is great for an electronic copy as everything can be zoomed in on and read; but I need paper printouts as well.  When printing from windows onto paper many of the diagrams are printed so small it is hard to read notations, etc.but my question is as follows:
    I am wondering how other people/companies have tackled this when there is a need to document everything within labview on paper?  Ideally we could end up with a book which has enlarged sections and could relate one page to another with metadata (sort of like those guide book maps - EG on the edges of the pages other pages are referenced for a continuation of the view). 
    I am open to other suggestions though. I guess I am wondering if there is a better way because the way I am considering doing this will be quite time consuming.

    When I was in the Air Force tech orders (manuals) typically had drawings that were too large to fit on a single page. The way they handled it was to have pages that folded out. Obviously you couldn't print these pages on a standard printer, but you could show diagrams without a lot of rescaling.
    Of course no printing scheme will work if the code is written badly (i.e. in adequate modularization, using sequence structures, wires running every which way, bad layout, etc.).
    Mike...
    Message Edited by mikeporter on 07-13-2007 08:07 PM
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Utilities to compile package source code and move into different instances

    Is there a native oracle utility that will take a source code for a package, compile it and then move it to a specific instances?

    The source for the current package is: \\PrimarySiteServer<FQDN>\SMS_PHC\Client
    To me, it looks like it's saying that it can't find the package at all, therefore no hash ID to evaluate.
    I dug around and found the following query under Monitoring: System Status, Status Message Queries, All Status Messages for a Specific Package at a Specific Site.
    After narrowing it to Package ID: PHC00002, it looks like around the time that it disappeared from all OSD TS, it started reporting the following:
    "Distribution Manager failed to process package "Configuration Manager Client Package" (package ID = PHC00002)."
    It would then retry, succeed, fail, retry, succeed, fail, etc. It did this for 24 hours before stopping all together.
    Here is the last entry, about 3 weeks ago: "Distribution Manager successfully processed package "" (package ID = PHC00002)."
    Since then it only evaluates the package on each DP every weekend on Saturday and it shows that it successfully verified each time.
    ...so it looks like its still stored on the DP's, but not otherwise available in the console.

  • Webui source code and documentation

    Is webui source code or documentation public available (classes from package oracle.ifs.clients.webui)? If i develope my own iFS web client can I reuse any webui classes?

    I have found answer, see URL: Re: Bug when RangeSize is greater than returned rows?

  • Why would I get different sized exe's if I build the same source code and target the same RT target?

    Hi Bob P (Dr. RT) et al,
    This is driving me nuts! I have a VI that uses different amount of memory depending on which machine I use to do the build.
    I use the same build file and the same source.
    It is targeted at the same cFP2000.
    FP version is the same.
    LV version is the same.
    If I build it from the one machine, there is enough memory available to target the RT platform, show the front panel and do a "show RT engine info".
    If I try this from the other machine, the cFP crashes, starts flashing the "status light" and latter on the crash dump file indicate "insuffiecient memory to complete this operation".
    The OS on the two machines are both XP. O
    ne is a laptop (the one that works) the other is a tower.
    Are there any LV ini file settings that could be hitting me?
    My customer is seeing the same issue, so it not just me.
    Any clues?
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

    Hi Bob,
    Few questions:
    1)Ftp to your target. Are the exes the same size on disk?
    No
    2)Build the exes on the hosts. Are they the same size on disk?
    I will have to look at this.
    3)Can you determine whether the exes consume the same amount of memory when loaded on the hosts?
    They will not run on the host because they use inport/output (to control serial port handshake lines).
    4)Does your application call any dlls via an NI driver or custom-built?
    THey use the "Settime.dll. At build time the builder says the target OS has its own version of this (and FP).
    I'm doubtful that any LV ini settings are causing this behavior. If I had to take a guess, it could be related to dll versioning. Do the hosts have identical versions of *all*
    drivers/dlls called by your app?"
    Can you give me a suggestion on how verify this.
    I have double checked LV (6.1) and FP.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Are there any techniques for memorizing source code and its place ?

    I forget stuff quickly so I have to start everything over and over again . I'm fed up with this ! Please help me ! Thanks .

    Fed up with what?
    What the heck are you talking about?

  • Anyway to have source code html, design view and CSS open windows at the same time?

    Hi all,
    Is there anyway I can keep design view, source code AND css open on screen all at the same time?
    Constantly clicking between source and css is really becoming irritating, would be so much easier if they were both on screen at the same time.
    Any help would be great

    You have two choices.
    1 You can go to preferences>general and the very first item (in CS6) is "open document in tabs" if you deselct that then you can view your page in split view and also open up the CSS file and have it visible as well.
    2 If you use tabs you can view the page in split view and open the CSS file and then detach the css from the tab and it will be an idependent item. You detach it by highlighting the tab and then dragging it down.
    It helps to have a large screen, and better still to have more than one screen, you can put the css on the other screen.
    VL Branko

  • Compare Development DB and Production DB objects source code

    Hi All
    We want to compare the Dev. DB and Prod. DB objects source code and list down all the objects which are different in the source code.
    1). Development DB and Production DB are in different network environment
    2). List down all the objects from Dev DB or Prod DB for which the source code is not matching with other DB
    Thank you
    Regards
    Gattu Anju

    There are many tools available. Personally I like the Change Management Pack option for Orqacle Enterprise Manager.

  • Ask again:  Where can I find source code for CPRM algorithm?

    Hi, everyone.
    Where can I find reference implementation or some sample codes for CPRM(content protection for recordable media) algorithm? Can anyone help?
    Information about CPRM can be find here,
    http://www.4centity.com/
    JAVA version is preferred and C/C++ implementation is also OK.
    Thanks in advance,
    Geo

    Thanks, edsonw buddy!
    I only found C2 cipher source code and some other documents dealing with CPRM algorithm. And what I want is total CPRM implementation reference source code (C2 is only a basic module of CPRM algorithm).
    So can you provide me some useful information dealing with how to get total CPRM implementation reference source code? Both JAVA and C/C++ will be OK.
    Have a wonderful weekend,
    George

  • How to view RUN_REPORT_OBJECT buil-in package source code

    Ps help.
    I'm creating a batch report that will execute from PL/SQL not forms - so I can't use this built-in directly on my PL/SQL procedure. How do I view RUN_REPORT_OBJECT source code and that of the functions that it calls.
    Thanks
    Khombi

    You can't see source code of this package.
    You can use srw package. Please see the following link.
    http://download-uk.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_evnt.htm

  • How to view RUN_REPORT_OBJECT built-in source code

    Ps help.
    I'm creating a batch report that will execute from PL/SQL not forms - so I can't use this built-in directly on my PL/SQL procedure. How do I view RUN_REPORT_OBJECT source code and that of the functions that it calls.
    Thanks
    Khombi

    good question for the report forum :
    Reports

  • How to read the Java source code (in Netbeans)

    I use OS X10.5.5, NetBeans 6.1 and JSE 6 on a 64 bit mac.
    When I downloaded NB6.1 it had JSE 5 as it's default (and only) java platform. I ran Software Update to get Java 6 from Apple, used the Java Prefrences utitlity to set JSE6 as default. In NB I added the JDK6 platform, registered the JDK6 javadocs and noticed that I also have the option of registering the Java source code.
    I have three questions:
    1) How do I make JDK6 the default in NetBeans. The JDK5 keeps being default after I did the steps above and I don't see anywhere to change that.
    2) How do I read the Java 6 source code? I can see sun provides [source code| http://download.java.net/jdk6/] for their supported platforms. I dont see Apple doing the same for its JDK port. What would I need to do to get to read the java SE6 sources? or is it actually hiding somewhere in the /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home hierarchy?
    3) Where does the JVM look for the binary code to run when I make a call to, say java.util.ArrayList or any other library. In my naivety I would have assumed it would be a .class file somewhere in the java Home folder, but I don't see anything like it.
    thanks in advance,
    chris

    This is taken from the help included with netbeans. In response to question 1.
    By default, the IDE uses the version of the Java SE platform (JDK) with which the IDE runs as the default Java platform
    for compilation, execution, and debugging. You can view your IDE's JDK version by choosing Help > About and clicking the
    Detail tab. The JDK version is listed in the Java field.
    You can run the IDE with a different JDK version by starting the IDE with the --jdkhome jdk-home-dir switch on the command line
    or in your IDE-HOME/etc/netbeans.conf file. For more information, see IDE Startup Parameters.
    In the IDE, you can register multiple Java platforms and attach Javadoc and source code to each platform. For example, if you
    want to work with the new features introduced in JDK 5.0, you would either run the IDE on JDK 5.0 or register JDK 5.0 as a
    platform and attach the source code and Javadoc to the platform.
    In  , you can switch the target JDK in the Project Properties dialog box. In  , you have to set the target JDK in the Ant script itself,
    then specify the source/binary format in the Project Properties dialog box.
    To register a new Java platform:
    Choose Tools > Java Platforms from the main window.
    Click New Platform and select the directory that contains the Java platform. Java platform directories are marked with a  
    in the file chooser.
    Use the Sources and Javadoc tabs to attach Javadoc documentation and source code for debugging to the platform.
    Click Close.
    To set the default Java platform for a standard project:
    Right-click the project's root node in the Projects window and choose Properties.
    In the Project Properties dialog box, select the Libraries node in the left pane.
    Choose the desired Java platform in the Java Platform combo box.
    Switching the target JDK for a standard project does the following:
    Offers the new target JDK's classes for code completion.
    If available, displays the target JDK's source code and Javadoc documentation.
    Uses the target JDK's executables (javac and java) to compile and execute your application.
    Compiles your source code against the target JDK's libraries.
    If you want to register additional Java platforms with the IDE, you can do so by clicking the Manage Platforms button.
    Then click the Add Platform button and navigate to the desired platform.
    To set the target Java platform for a free-form project:
    In your Ant script, set the target JDK as desired in the javac, java, and javadoc tasks.
    Right-click the project's root node in the Projects window and choose Properties.
    In the Sources panel, set the level of JDK you want your application to be run on in the Source/Binary Format combo box.
    When you access Javadoc or source code for JDK classes, the IDE searches the Java platforms registered in the
    Java Platform Manager for a platform with a matching version number. If no matching platform is found, the IDE's default platform is used instead.
    See Also
    Managing the Classpath
    Declaring the Classpath in a Free-Form Project
    Stepping Through Your Program
    Legal Notices

  • Unable to write, type anything in source code of a function module.

    Hi all,
    We have a registered name space for our client called /ABCD/EFG.
    I need to create a function module in the name space.
    So first I created a Function Group called /ABCD/EFG_FG in /ABCD/EFG. I activated it in se80.
    Then I created a Function Module called /ABCD/EFG_FM in /ABCD/EFG. I declared the import and export paramters and now I am trying to add the code in source code and the editor does not let me change the source code donu2019t know why.. and every thing is in grey color.
    Can some one tell me what is going wrong? Cant we write any logic in the function module that we create in registered name spaces? When I created the same function module as a local object in $TMP package I dint have any problem. Similarly I created the function module in a Z package and I dint have any problem but if I try to create the same function module in a registered name space it is getting created but it doesnu2019t not let me type anything in the source code of the function module.
    Did any body encounter this problem earlier? Kindly please help.
    Regards,
    Jessica Sam

    Rich,
    Thanks a lot, that worked. Now it lets me type and change the source code of the editor.
    But while i was turing off the assistant it showed me 2-3 messages saying that "i cannot track the changes" and that "during upgrade i cant track the changes " etc.
    So now i can type in source code and i am able to change in source code..but will the trurning of this assistant cause any problmes in future or during upgrade?
    Regards,
    Jessica Sam

Maybe you are looking for

  • No Sound on Satellite A105-S4201

    I recently lost all sound on my Satillite A105-S4201.  In Device Manager, under Sound and Video Devices, there are numerous yellow flags (too numerous to name here).  I attempted to install the device driver (Realtek HD) from the Toshiba Recovery CD

  • Flash CS3 Exe won't open in Explorer/Firefox

    I have created a project in Flash CS3 and exported it. I "embedded" a link in an HTML document. When I click on the link in Firefox I only get the option to download. When I click on it I get the choice to open or save & when I choose "open" I get th

  • Sorting search results by rank

    Hi, Is it possible to sort the search results by rank in RH8 html help ? It works when I click on Title but not when Rank is clicked. What I mean is changing from ascending to descending order. Thanks,

  • How do I backup to a webserver?

    Hi, I am a web developer and have a web server that I would like to backup my files to via Time Machine. My understanding is that I would have to mount the filesystem (server) so it appears as a network drive on my desktop, and then Time Machine woul

  • Apple Mail on Snow Leopard 10.6.7?

    Where can I download the current version of Apple Mail that will run on Snow Leopard 10.6.7?