How To Make A Program Which When I Press A Button The Number Goes Up One?

I have already made this:
import java.awt.Container;
import java.awt.LayoutManager;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
public class Lab04 extends JFrame
private Container content;
private LayoutManager layout;
private JLabel number, division, modulus, space;
private JTextField text;
private String string;
private ActionListener listener;
private char char1;
private int x, Add1, Add2;
private JButton bAdd;
public Lab04()
formatWindow();
listener = new Handler();
bAdd = createAndAddButton("+1");
number = createAndAddLabel("Current Number: 0");
division = createAndAddLabel(" n DIV 4 = 0");
space = createAndAddLabel(" ");
modulus = createAndAddLabel(" n MOD 4 = 0");
public void formatWindow()
content = getContentPane();
layout = new FlowLayout();
content.setLayout(layout);
private JLabel createAndAddLabel(String s)
JLabel temp = new JLabel();
temp.setText(s);
content.add(temp);
return temp;
private JTextField createAndAddTextField(int x)
JTextField temp = new JTextField(x);
temp.addActionListener(listener);
content.add(temp);
return temp;
private JButton createAndAddButton(String s)
JButton temp = new JButton();
temp.setText(s);
temp.addActionListener(listener);
content.add(temp);
return temp;
private void process()
int x = 0;
Add1 = x +1;
private void output()
number.setText("Current Number: "+x+1);
private class Handler implements ActionListener
public void actionPerformed(ActionEvent e)
process();
output();
public static void main(String[] args)
//create graphics window
Lab04 window = new Lab04();
//configure graphics window
window.setSize(200, 150);
window.setLocation(300, 175);
window.setTitle("Unit 3 Lab03: Filling Out Forms");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//display graphics window
window.setVisible(true);
And all it does is it gives me the number 01, what should I do?

public void process{
int x = 0;
Add1 = x +1;
}just what is this supposed to do? every time you call it, it create a primitive x with value 0, and then makes Add1 equal to x+1. that will be 1 no matter how many times you call it.

Similar Messages

  • I want to create a vb form in which when i pressed a button then a specific song must be played.

    i want to create a vb form in which when i pressed a button then a
    specific song must be played. will u plx help me to do this..what i mean is that when i pressed that button a audio msut be played. will anyone help

    i want to create a vb form in which when i pressed a button then a specific
    song must be played. will u plx help me to do this..what i mean is that when i pressed that button a audio msut be played. will anyone help
    My.Computer.Audio.Play("C:\Users\John\Desktop\Something.Wav",
    AudioPlayMode.Background) or My.Computer.Audio.Play(My.Resources.SomeWavFileinyourresources,
    AudioPlayMode.Background) will play .Wav files only. And it will play them directly from resources without having to write them to disk to play them first.
    The
    Windows Media Player Control (can be created dynamically and not displayed) or the
    Media Player Class or a third party control that you can download called
    VLC Media Player can all play audio files based on the Codecs they use or have installed. Which would be .Wav, .MP3 and some others as well as you can download third party Codecs that can be provided to your system possibly for the Media Player class to
    use but as plugins I believe for Windows Media Player and VLC Media Player I believe for playing other types of audio and video file formats that they do not directly support with their installed codecs. Although all of these require that a file is available
    from disk or thumbdrive or CD Rom to play and can not directly play resources therefore resources must be written to disk in order to work.
    Microsoft Visual Basic language forum search results for "WindowsMediaPlayer"
    Microsoft Visual Basic language forum search results for "MediaPlayer"
    La vida loca

  • I inserted a HTML5 video in page, when I test it in a Browser, I see the poster image and controls, But when I click play button the video goes white, slider moves like its playing, but just white picture. There was no audio included in video. Please help

    I inserted a HTML5 video in page, when I test it in a Browser, I see the poster image and controls, But when I click play button the video goes white, slider moves like its playing, but just white picture. There was no audio included in video. Please help

    Without a link, it's anybody's guess.
    It could be a problem the video rendering itself.  Which software did you use?
    Did you export to the 3 file types -- MP4, OGG and WEBM to support all browsers?
    Does your web server support those 3 MIME file types?
    Nancy O.

  • HT1555 i just got a new apple tv but for some reason the remote only worked for about a min. and than it wount work at all. i tried to pair and unpair but nathing works but when i press a button the light on the apple tv turns off. what should i do?

    i just got a new apple tv but for some reason the remote only worked for about a min. and than it wount work at all. i tried to pair and unpair but nathing works but when i press a button the light on the apple tv turns off. what should i do?

    Have you held the menu and left arrow together for 6 secs ?  (I think you have from what you say).
    Also try unpowering and restarting AppleTV.
    AC

  • When making a call, sometimes, my iPhone 5 , gets stuck on 'Calling' than I have to press END..but still nothing happens, than when I press HOME button, the call app keeps running in the background and it keeps saying CALLING... please help

    When making a call, sometimes, my iPhone 5 , gets stuck on 'Calling' than I have to press END..but still nothing happens, than when I press HOME button, the call app keeps running in the background and it keeps saying CALLING... than I have to wait 2 - 3 minutes and call again.
    please help

    Has nothing to do with the SIM or master reset.  This has been done to my phone.  The SIM once and the factory reset many times over.  You all just sold us a bad piece of equipment and have us by the tail with our contracts so none of us can get a new phone without paying full price or re-upping our contract.  I just got off the phone last night with your high up tech people (you know, the hidden number we get once we tear into your support people enough), they went into my phone again and still didn't find anything wrong.  I about got fired from my job for not getting my calls and texts.  The BBB has now been contacted, and I feel your end should shore this up for all of us!

  • How to write a UDF which when encountered it should stop the map

    hi all,
    My task is to write a UDF which when encountered it should stop the map and return what is given as an input to the UDF For ex: UDF(map failed!)
    when this udf is encountered than the map should stop and the output output should be mapfailed!

    <i>But over there it is given to stop a particular mapping step only But my requirement is that i should stop the Entire Mapping process</i>
    UDFs r used in graphical mappings and the details in blog shows that when a UDF stops a mapping, it in turn stops whole messgae mapping. So ur entire Mapping process would get stopped
    Regards,
    Prateek

  • How to make a program that will ask for a name the first time the program is used and if is not the first time will not ask the name?

    I want to make a program that will ask for the ID of the testing machine the first time the program is running, then will never ask for it. I'm using Labview 6.0

    Hi
    There are a Couple of methods you can use for this.
    Method 1 -
    You can create an ini file and save a boolean Key "First Instance" as True. Now In your Program you read this Key, If it is True then you can show your ID Dialog VI.If False do not run the VI. At the Conclusion of Id Dialog you can update this registry enrty to False. So In effect you have created One time Event. In fact you can save ID as another Config entry.
    The Drawback and advantage is that such an INI file can be edited by someone moderately knowledgeable about the Program
    Method 2
    Use Unitialized Shift Register in A while Loop. Please see LV2 style Globals entry under this forum. You can read and write to this Variable and it retains the Value it last had within it.
    You can read
    this Global the Very first time and say if it true you display your ID Vi. If False you dont. When you display your ID Vi you can Update your Global Like Before.
    If you need Example Let me Know.
    Good Luck
    Mache!!
    Good Luck!
    Mache

  • Macbook pro is not getting turn on and further when i press power button the green orange light suddenly changes to green again, moreover battery meter is not working

    Hi
    Last night my macbook pro gets off automatically when battery gets empty and in the morning it isn't turning on. When i connect the charger, the light on the charger turns green to orange (showing that it is charging) but when i press the power button it suddenly changes to green again. I thought there must not be any connection between the charger light and the power button. And battery meter was running fine.
    When it tried this again and again the charger light disappear and battery meter also stops working, when i clearly observe it there is a very dim green light in the charger (not observable in the light) and the laptop is still not showing any change.
    please help!

    Try Resetting the System Management Controller (SMC)
    Apple - Batteries - Notebooks

  • My retina iPad make a cracking sound when you press slightly in the area around the front cam. sounds like scotch tape that doesn't stick properly. Anyone having that too?

    Ì fear that the cover will crack open over time.

    Well I bought it 3 weeks ago, looks like I need to visit the store where it is from. Unfortunately there is no apple store in Vienna Austria yet
    thx
    J

  • In windows 7, how to make firefox start automatically when I turn on the computer

    In Windows 7, how to make Firefox start automatically when I turn on the computer. Note, I am asking how to do this with Windows 7, not xp, not vista.

    You need to place a shortcut to open Firefox in the Start > Programs > Startup folder.<br />
    That is basically the same in all Windows versions.

  • How to make my program forcefully errror

    hi 2 all
    how to make my program forcefully error out even i have to get data
    regards
    siva

    Hi Mate,
    Just remove the quries which you execute
    Thanks
    Kash
    www.mkashu.blogspot.com

  • How to make a program for backgroung processing used servlet

    how to make a program for backgroung processing used servlet

    well i need the coding part written in servlet ,in which servlet is always ready for accepting a client request.

  • HI, I need your help. How can I delete all data, when I do not have the special security code, which I didn´t remember ? I also think, that I never create this code before. But I cannot put my settings back.

    HI, I need your help. How can I delete all data, when I do not have the special security code, which I didn´t remember ? I also think, that I never create this code before. But I cannot put my settings back.

    You must remember the code, if you can't then take the phone and proof of purchase to an Apple Store.

  • How to make labview program to get average value of 200 reading from multimeter (by using loop)

    Hello
    How to make labview program to get average value of 200 reading from multimeter (I using using loop) to read voltage from mulmeter  but I like to get average value of all of 200 reding how can I do that?
    Thanks
    Wee
    Solved!
    Go to Solution.

    Another idea with less programming - take advantage of the "free" array that comes with a Chart - i.e. the  History Data.
    1) Wire your DMM data to a Chart. (You can set the chart to invisible if you don't plan on using it in the GUI).
    2) Set the Chart History Length to 200 (right click on the chart, click on Chart History Length...)
    3) On the block diagram, use the History Data Property Node, wire it to Mean.vi, and you're done.
    Easiest running average ever.
    Message Edited by Broken Arrow on 04-07-2010 11:36 AM
    Richard
    Attachments:
    EasyAvg.jpg ‏8 KB

  • I put in my gift card code and at the top of my home page it says that I have 15 dollars. When I go to purchase it still makes me put in the code and says that it invalid. How do I pay for something when I already put in the code? please help

    I put in my gift card code and at the top of my home page it says that I have 15 dollars. When I go to purchase it still makes me put in the code and says that it invalid. How do I pay for something when I already put in the code? please help

    See Here  >  http://support.apple.com/kb/TS1646
    If no joy...
    Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

Maybe you are looking for

  • How to make a color wheel?

    I'm using CS4 on a Mac. I need to make a color wheel, like the attached, but with 24 segments. Could someone tell me how? Start with a circle, obviously, and then what?

  • Pagination issues in Word output from RoboHelp HTML 8

    Hi All, We're generating a Word document from our online help (RoboHelp HTML 8) with MS Word 2003 installed. The page numbers inserted automatically are wrong in that it's skipping numbers. For example, in scrolling down through the document, the pag

  • Payment and cannot active the account

    Last mont I wanted to use skype phone and I enter my paypal account, but I couldn't use the call service. After 1 month this money was less from my paypal.Now everyday I have tried to give my number in skype and receive a confirmation code to active

  • How to install oracle apps 11.5.10.2 on WinXP?

    How to install oracle apps 11.5.10.2 on WinXP?

  • Error  when instantiating a Com( EXCEL.APPLICATION) object in WINDOWS XP

    Hi, I am using coldfusion MX7 and OS is WindowXP. I am using COM object with Excel.Application for my program. but it is giving the below error. But same program is working in Window Profesional. ERROR IS: An exception occurred when instantiating a C