Clearing the input box

When I make a program that asks the user to input two integers and then the program computes the sum and displays it, I noticed that every time I re-run the program the previous first integer that was entered is still sitting in the input box. I've made this same program in both Eclipse and JDeveloper and neither one of those do this. It's rather annoying to re-run the program and to be looking at the input box and it still has previous input stuck in it.
Just wondering if there is any way to clear the input box automatically upon re-running the program.

This is just a console application. When I say re-run, I mean after you are done looking at the output, you hit the run button again to run the program again and have fun entering in new integer values. That's what I like to do with most of my programs. Here is the code:
import java.util.*;
public class GettingInput {
    public static void main(String args[])
        // create Scanner to obtain input from command window
        Scanner input = new Scanner( System.in );           
        int number1; // first number to add  
        int number2; // second number to add 
        int sum; // sum of number1 and number2
        System.out.println( "Enter first integer: " ); // prompt
        number1 = input.nextInt(); // read first number from user
        System.out.println( "Enter second integer: " ); // prompt
        number2 = input.nextInt(); // read second number from user
        sum = number1 + number2; // add numbers
        System.out.print( "The sum is " + sum);
}Getting back to that JComponent thing, in order to make the setText( ) thing work, would I just include an import JComponent statement at the top of my code or what?

Similar Messages

  • Clearing the Combo Box

    Guys,
    I have two combo boxes in my model. Which the User can type in and then select the particular <b>Employee ID</b> and <b>Employee Name</b>.
    The issue is, once something is selected, lets say for example I select Employee ID "345" and run it. It brings everything for Employee ID "345".
    After I do that, I want to check on Employee Name "HORRIBLE", when I do that it <i>does get me</i> the details for Employee Name "HORRIBLE", but <b><i>does not clear the other box</i></b> "Employee ID" which is still showing "345".
    Is there a way to clear the other combo box when I select something from one box?
    waiting for a response,
    Thanks a lot guys,
    Naseer

    Hi Nasser ,
    Just check whether you can make use of event to fullfil your requirement.
    Thanx
    Pankaj

  • How do i remove this feature? where using google maps the input box has this in it( Enter your address line 2 here)/In hotmailmail new email it reads (Enter your email here) e

    how do i remove this feature? where using google maps the input box has this in it( Enter your address line 2 here)/In hotmail new email on the enter page it reads (Enter your email here) .
    You have the remove these statements before entering an address , and before sending an email or with the email it will stay on the email , google maps will not work.

    Try this -
    <img src="assets/jpgs/Prodigy Logo Large 2014.jpg" width="180" height="180" alt="" style="display:block;">
    What you are seeing as whitespace is the space reserved for glyph descenders on any element that is rendered within a text box (i.e., an inline element). By making the image "display:block" you eliminate that space because a block element doesn't have descenders. If that works to your satisfaction then you can give the logo an id, and create a CSS selector containing that block style.

  • What if i have a large question, bigger than the input box

    what if i have a large worded question on this forum, bigger than the input box?
    i know it scrolls, but i quite often have something more than a line of text as a question ,and would like to see all of what i have to say?

    The title/subject of a topic shouldn't be more than a few words that summarize the nature of your question.  Long topics, and other useless ones such as HELP ME!, don't do much to attact the correct amount of attention, and can actually drive away potential help.  What your topic question should do is give others an idea about whether they should open your topic rather than one of the hundreds of others, i.e. if it is something they now about or are interested in - use the message body to go into details.

  • How can I change the height of the input box in a...

    How can I change the height of the  input box in a new version of Skype?
    Solved!
    Go to Solution.
    Attachments:
    Skype_input_box.png ‏4 KB

    lucasbgme wrote:
    I've tried 6.1.0.129
    6.1.0.129 version is disabled. All Skype versions older than 6.14 are now retired and can no longer be used. You can try to install the 6.21.0.104 version:
    http://download.skype.com/msi/SkypeSetup_6.21.0.104.msi

  • How to Clear the Input errors in a Cisco ASA Interface?

    Hi Everyone,
                      My Expertise with Cisco ASA is Very less. I have observed Input errors in a Couple of Interfaces in Cisco ASA 5540 Firewall.  
    296867 input errors, 0 CRC, 0 frame, 296867 overrun, 0 ignored, 0 abort
    0 pause input, 0 resume input
    0 L2 decode drops
    102091138038 packets output, 96596756282996 bytes, 2683 underruns
    0 pause output, 0 resume output
    0 output errors, 0 collisions, 2 interface resets
    0 late collisions, 0 deferred
    52 input reset drops, 0 output reset drops, 0 tx hangs
    input queue (blocks free curr/low): hardware (255/230)
    output queue (blocks free curr/low): hardware (255/0)
    I need to Clear the Input errors on this particular Interface.
    Will Clear interface GigabitEthernet 0/0 will help?
    Thanks in Advance,
    Nanda

    Hi,
    Here is an example of using the command on my own ASA5505 firewall
    interface Ethernet0/0
    description WAN Access
    switchport access vlan 10
    ASA# sh interface Ethernet 0/0
    Interface Ethernet0/0 "", is up, line protocol is up
      Hardware is 88E6095, BW 100 Mbps, DLY 100 usec
            Auto-Duplex(Full-duplex), Auto-Speed(100 Mbps)
            Input flow control is unsupported, output flow control is unsupported
            Description: WAN Access
            Available but not configured via nameif
            MAC address 0025.45f4.0a9a, MTU not set
            IP address unassigned
            9679 packets input, 6532697 bytes, 0 no buffer
            Received 2 broadcasts, 0 runts, 0 giants
            0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
            0 pause input, 0 resume input
            0 L2 decode drops
            0 switch ingress policy drops
            8421 packets output, 2202683 bytes, 0 underruns
            0 pause output, 0 resume output
            0 output errors, 0 collisions, 0 interface resets
            0 late collisions, 0 deferred
            0 rate limit drops
            0 switch egress policy drops
            0 input reset drops, 0 output reset drops
    ASA# clear interface Ethernet0/0
    ASA# sh interface Ethernet 0/0
    Interface Ethernet0/0 "", is up, line protocol is up
      Hardware is 88E6095, BW 100 Mbps, DLY 100 usec
            Auto-Duplex(Full-duplex), Auto-Speed(100 Mbps)
            Input flow control is unsupported, output flow control is unsupported
            Description: WAN Access
            Available but not configured via nameif
            MAC address 0025.45f4.0a9a, MTU not set
            IP address unassigned
            0 packets input, 0 bytes, 0 no buffer
            Received 0 broadcasts, 0 runts, 0 giants
            0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
            0 pause input, 0 resume input
            0 L2 decode drops
            0 switch ingress policy drops
            0 packets output, 0 bytes, 0 underruns
            0 pause output, 0 resume output
            0 output errors, 0 collisions, 0 interface resets
            0 late collisions, 0 deferred
            0 rate limit drops
            0 switch egress policy drops
            0 input reset drops, 0 output reset drops
    interface Ethernet0/0
    description WAN Access
    switchport access vlan 10
    - Jouni

  • My new windows 7 machine and firefox color defaults for input boxes are obscurring the input box on the google search page making google unusable

    Under Windows 7 Firefox looks quite different including the default blue for input to question boxes which are white on the xp machines. Normally this is not a problem. But on the Google web page the blue is so bold that nothing can be seen except for a very small portion of the characters (in red) extending below the input screen. This becomes miserable if you try to edit a search stmt or backspace to correct a spelling error. you are quickly lost and need to clear the cache and reload the page.
    This problem does not appear using Chrome or IE on the same machine. Nor is it a problem using Firefox 9.0.1 on two other home PC's running XP (there no input box obscures the answer). This seems to be a lot of work.

    That can be caused by the "Keystroke protection" in Comcast Constant Guard.<br />
    "Configure Anti-Keylogging Settings" -> disable
    *[[/questions/874709]]
    *[[/questions/870165]]

  • Clear an input box with failed validation status

    My jdev version is 11.1.1.5.0
    I have an input box with certain validation.If validation fails it doesnt clear its contents on button click.
    My button click code is :
    propButton.setValue(null);
    where propButton is binding name to button.

    Hi Lovin,
    How are you actually validating? Is it by <f:Validator> Tag, or Validation in the Button click code?
    If its in button click code: Refreshing programmatically in the button code, will ensure that the value is cleared in the inputTextBox and then refreshed.
    Refreshing programmatically:
    First, create a binding to the InputText Box in a managed bean, using the Binding attribute.
    binding="#{managedBeanName.inputTextBox}"
    public void clickButton(ActionEvent ae){
    this.getInputTextBox().setValue(null);
    AdfFacesContext.getCurrentInstance().addPartialTarget(this.getInputTextBox());
    Thanks,
    Pandu

  • How to clear the input values in WD4A

    Hi all,
    Thanks in Advance.
    In my login page i have ID and Password.If Login fails it back to the same login page.But at the same time the entered(In ID and Password)will be cleared.If i write the code in inboundhandler is it correct means how can i write to invalidate the input values???Is there any examples or related links???

    Hi,
    Please have a look at this similar thread:
    how to clear entered values.
    Hope this helps!
    Regards,
    Srilatha

  • Clearing the input field

    After executing a report, the green arrow back key will takes us back to the selection screen with the original input on it.
    However, I would like to see the selection screen without any previous input on it, so I could start entering new input without deleting/overwriting the old ones. Is it possible to do that?

    hi there...
    for the second part, the logic is as i gave above....
    for the first part, you need to use screen end-screen.
    set the attribute active inside the screen end screen to enabled on the press of the change button. before that, set it to disabled.
    you can press f1 on screen to get the entire help on how to use screen end screen .
    hope it helps.

  • How to clear the input fields

    when I click on search button, I get the search result, but along with those results, I see some input fields automatically assigned the values in the search input, which should not be.
    values are assigned to these fields because of controller context field values, once the values are populated these values are assigned everywhere where istle feild referring to.
    How to keep the user input without changes?
    Thanks!

    Naveen,
    You set contradictory requirements: on one hand you have mapping, where values are always synchronized; on other hand you whant them to be unique.
    Just break your existing mappings.
    1. Create separate attributes in view context(s) if you do not need to access them in component controller or you do not need to be synchronized between views.
    2. Create unique set of attributes in component controller for combination of attributes that really must be synchronized. Then map view context attributes accordingly.
    VS

  • How to capture the data input in the input box like text box  on webpage?

    I would like to know how to use the data we key in in the textbox on the webpage and write it to database using JSP

    I would like to know how to use the data we key in in
    the textbox on the webpage and write it to database
    using JSPIf you want to store it into database....you'll need that
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:YourDSN");
    Statement stat = con.createStatement();
    String query = "INSERT INTO yourTable (Field) VALUES(TextBox value)";
    stat.executeQuery(query);
    con.close()
    Not tested but should work (depends also on your configuration)

  • I have a dialog window on my iPad2 labeled iCloud Bakup -- the iPad hasn't been backed up in 4 weeks. The screen is frozen. I can't clear away the dialog box to close down iPad and I can't get to settings to make any changes there. Ideas?

    A dialog box has appeared on the screen of my iPad2 and has frozen the device so that I can't close it down or make changes to the settings. The titel is "iCloud Backup" and it reads: This iPad hasn't been backed up in 4 weeks. Backups happen when this iPad is plugged in, locked, and connected to WiFi.
    I'm not sure why it hasn't backed up but I can't do anything to clear the dialog box, turn off the device or get to any settings or apps on the device.
    Any suggestions? Please help -- I'm caring for my mother in hospice and don't have time to deal with this at the Apple Store!

    Welcome to Apple Support Communities
    Hold Sleep and Home buttons for 10 seconds until the device restarts, so you will be able to use the iPad again.
    It will try to make a backup every time your iPad is plugged to the charger and connected to a network. To prevent that this message appears soon, open Settings > iCloud > Storage & Backup, and choose Backup Now

  • ICal problem--an error box comes up an won't go away. I can't close the error box and I can't activate the calendar because the error box needs to be cleared. There is no place on the box to click in order to close it.

    I have a problem that just affects iCal. An error box popped up when I was trying to past something into a new appointment. The box blocks me from using the calendar. I can't clear the error box. It has nowhere to click to close it. Nothing happpens when I right click it. I have force closed iCal, but when it reopens the error box is still there blocking any use of the calendar. There is no error number, just a copy of the text I was trying to paste.

    Try this.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Allow the user to control the width of the edit forum post input box

    I would like to control the width of of the edit-forum post input box.  This could be:
    automatically adjust the width of the box so that the box doesn't run off the right edge of the window.
    have a user global preference to set the preferred width
    at least, allow the user to change the width via the change size icon.  The three horizontal bars at the lower left of the input box. You can adjust the vertical dimension, but not the horizontal. TenFourFox 4.0.1. This is probably being blocked for some obscure reason.
    Here is an example of an over extended right margin:
    Curiously enough, the "software" let's me adjust the width & height of the add reason to edit text, but not adjust the width of the more important edit text box.
    Robert

    Testing
    Standard Reply box can be height adjusted but not width.
    Same with Advanced Editor
    No Adjustment at all in HTL Editor
    Edit.
    The Edit uses the Advanced Editor
    Only Height Adjustment again.
    I do seem to remember someone posting about the width and saying they could drag it over the edge of the right hand edge (Into the grey surround)
    This may have been a post in the lounge.
    It didn't actually try it at the time but have played with it since and have not seen it.
    Maybe it is something they "Fixed" in both senses of the word.
    Second edit.
    I can't alter the box that currently reads "Message Edited by:- ..."
    I also can't get this box to accept New lines  (they appear in the box but don't post that way)
    Corrected Spelling
    9:51 PM      Wednesday; May 11, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
     Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously
    Message was edited by: Ralph Johns (UK)
    Message was edited by: Ralph Johns (UK)
    and new line with a line space as well

Maybe you are looking for

  • How to restrict editing of some paragraphs and allow for others in same document?

    I have a client that wants to put together standard proposals that have boiler plate information (long paragraphs and some imagery) that will not change. In the same document they have other information that is to be customized by sales teams (text a

  • How to use a Text View to show the current user

    Hi Experts, I am using a Text View to show the current logged on user. Also i need to retrieve the date of creation of proposal and show it as output parameter. I am using the following code but it is not working properly. Please help me out regardin

  • Nokia E5-00 firmware v042.014

    Please i want to know if there is any problem with this firmware v042.014. Just got available in Nigeria today. And i don't want to update to a firmware that has issues because it is not downgradable. Thank you in advance.

  • HT2736 recipients are not receiving gifted music

    I've gifted music, but they are not receiving it?

  • How to receive the items in purchasing in Fusion

    Hi, I created a Purchase Order and approved it. ( there is No Requisition created) I went to receiving from (Navigator->Under Procurements, there is Receipts). and when i queried by the above created Purchase Order, Its not showing anything. Can you