Results 1 to 7 of 7
  1. #1
    jini is offline Member
    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0

    Unhappy I know you have seen this before but - HELP!

    IT Professional accepted to the UIS CS program unexpectedly. In my first programming class - I prefer networking - and the text does not cover what the professor instructs us to do.

    Using textprad, these are my instructions -

    Lab1: Write a program that displays a frame window W pixels wide and H pixels high. Use the Scanner to enter the values for W and H. The title of the frame is also entered by the user. Just submit Lab1ís Java source code

    I missed the latter part and have this code -


    /*
    My First Java Program: Displaying a Window
    File: MyFirstJavaProgram.java
    */
    import javax.swing.*;
    import java.util.*;
    class MyFirstJavaProgram {
    public static void main(String[] args) {
    JFrame myWindow;
    myWindow = new JFrame();
    myWindow.setSize(600, 400);
    myWindow.setTitle("My First Java Program");
    myWindow.setVisible(true);
    myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_C LOSE);
    }
    }

    The text section on using the scanner class only covers results via System.out.print and I am left hanging :(
    The goal fo the lab is to open a window at a certain size. I do not see how to do both - open a window of a certain size in H and W and out print the results.

    Help? Please?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,015
    Rep Power
    10

    Default Re: I know you have seen this before but - HELP!

    Some friendly advice: stop complaining about your instructor or your class.

    Take a look at the tutorials for the Scanner class as well as the API. Try something out, and we'll go from there.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    jini is offline Member
    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0

    Default Re: I know you have seen this before but - HELP!

    Good Evening Kevin-

    My apologies if I have given the impression of complaining about my professor and class. That certainly is not my intention. I am an non traditional student age wise, that has transferred with a 3.66 GPA dual majoring in IT and Cellular Tech. I have made it through some very difficult classesand am not looking for an easy answer. My posting to this forum was after google searching more information on the scanner class and how it can be used. I am having some kind of blockage getting this and the the text only shows one example usage of the scanner class and to me it does not mesh with the result the java application is supposed to return and have found no other instances in my research to assist me.

    Quote Originally Posted by KevinWorkman View Post
    Some friendly advice: stop complaining about your instructor or your class.

    Take a look at the tutorials for the Scanner class as well as the API. Try something out, and we'll go from there.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,015
    Rep Power
    10

    Default Re: I know you have seen this before but - HELP!

    Well, I don't see anywhere in your code where you're using a scanner. Maybe forget about the frame part for a second and create a program that simply reads in some values from the user and prints them back out?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    jini is offline Member
    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0

    Default Re: I know you have seen this before but - HELP!

    Again, thank you for your response.

    You are correct there is no use of a scanner in my code. I was not clear on what I should take out or where I should use the scanner class. The text covered the useage of the scanner prompting user for first name, and then last name, with the result being 'your name is firstname, lastname. The most I could see doing with it in regards to the window lab was prompting for the input of H and W of the required window and the result saying 'your window is 600 W and 800 H.

    I am very discouraged that I am not getting this. I am considering just submitting two sets of code, one where the window opens at the size specified and the other using the scanner class. I do not know how to write the program to do both, take the input for H and W, printing the result and having a window open at that size.

    Quote Originally Posted by KevinWorkman View Post
    Well, I don't see anywhere in your code where you're using a scanner. Maybe forget about the frame part for a second and create a program that simply reads in some values from the user and prints them back out?

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: I know you have seen this before but - HELP!

    Use the Scanner to have the user input values (width, height, title). Assign those values to variables. Use those variables to create a Window/Frame. It really isn't that hard and you are probably over-thinking things.

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,015
    Rep Power
    10

    Default Re: I know you have seen this before but - HELP!

    Start by posting the program that uses the Scanner class (in SSCCE form), and we'll go from there.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Posting Permissions

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