How does one include a counter in an applet?

By counter, I mean you have a number in a label or text box and up/down arrows immediately to the right of it, when you press the down arrow the number goes down and vice versa for the up arrow.

I added a window listener so the default close operation for the
window manager can be used. The previous was not able to respond
to window manager events.
import java.awt.*;
import java.awt.event.*;
public class Counter extends Frame implements ActionListener {
private Label label;
private Button up, down;
private static int number = 0;
public Counter() {
     super("Test");
     setLayout(new FlowLayout());
     label = new Label(Integer.toString(number));
     up = new Button("Up");
     down = new Button("Down");
     add(label);
     add(up);
     add(down);
     up.addActionListener(Counter.this);
     down.addActionListener(Counter.this);
     addWindowListener(new WindowAdapter() {
     public void windowClosing(WindowEvent e) { dispose();}
     pack();
     setVisible(true);
public void actionPerformed(ActionEvent ae) {
     if (ae.getSource() == up) {
     label.setText(Integer.toString(++number));
     if (ae.getSource() == down) {
     label.setText(Integer.toString(--number));
public static void main(String args[]) {
     new Counter();
This below should do it. It does not listen for a
default close so
you might have to stop it by doing a Control-C.
This was compiled with and works with SDK 1.4.1_02.
import java.awt.*;
import java.awt.event.*;
public class Counter extends Frame implements
ActionListener {
private Label label;
private Button up, down;
private static int number = 0;
public Counter() {
super("Test");
setLayout(new FlowLayout());
label = new
label = new Label(Integer.toString(number));
up = new Button("Up");
down = new Button("Down");
add(label);
add(up);
add(down);
up.addActionListener(Counter.this);
down.addActionListener(Counter.this);
pack();
setVisible(true);
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == up) {
label.setText(Integer.toString(++number));
if (ae.getSource() == down) {
label.setText(Integer.toString(--number));
public static void main(String args[]) {
new Counter();

Similar Messages

  • HT5243 How does one know if they use "java applets"? What do they do? How will I know if I need to 'disable the java web plug-in browser' if I do not use them? ( I'm not very literate in computer-speak.

    How does one know if they use "java applets"? What do they do? How will I know if I need to 'disable the java web plug-in browser' if I do not use them? (Obviously I'm not very literate in computer-speak.)

    Well, when you go to a web page a section of the web page will have a coffee cup picture where the java applet will run. The applet loads then runs. If you are not seeing this behavior then you are not using java. If it make you feel more comfortable then disable the browser java plugin. On my machine I have not disable java- but you
    may what to.

  • While using Build App installer, how does one include drivers for hardware

    I have a LabView vi and I would like to create an application to be installed on a different computer that also requires a PCI-6503 digital IO card for the purpose. While using Build Application to create the installer, is there a way I can include the necessary hardware drivers for the DIO card?
       Thanks.
        -Bahadir

    Hi Bahadir,
    Your request for the option of including specific drivers (in your case NI-DAQmx)
    with the installer of your executable is something that is something we have
    heard from many customers. With any version of LabVIEW up to 7.1.1, you have
    always had to install the drivers separately or in best case by creating your
    own *.bat file that defines the installation procedure of the driver.
    However, LabVIEW 8 is here for
    your rescue! We have listened to our customers and now you have the simple
    option of putting a checkmark for the option of the driver you want to be
    distributed with your installer. Check these options from the Installer
    Provider:
    Please read more about the new possibilities with LabVIEW 8 from this tutorial:
    Distributing
    Applications with the LabVIEW Application Builder
    The best part of it all is that you can try it all
    (including Application Builder) out by downloading the Evaluation version here:
    LabVIEW
    8 Evaluation Software Download
    Notice that the Evaluation version of LabVIEW 8 is similar
    to the Professional Development System, except from a watermark and the fact
    that is only runs for 30 days. Everything else is possible!!!
    Try out LabVIEW 8 and check out all the other places we have
    listened to our customers...
    Have fun!
    - Philip Courtois, Thinkbot Solutions

  • How does one know if the latest Camera Raw is included Photoshop CC?

    How does one know if the latest Camera Raw is included  with Photoshop CC?

    Help>About Plug-In>Camera Raw...

  • How does one obtain specific fonts and are they included in Creative Cloud membership?

    How does one obtain specific fonts and are they included in Creative Cloud?

    What fonts? There's a whole slew of fonts available with typeKit, which is included in CC, but specific fonts may still require to be bought individually from the respective type foundries.
    Mylenium

  • How does one change the font size for folders and/or file lists in the Bookmarks Library?

    How does one change the font size for folders and/or file lists in the '''Bookmarks''' Library?
    Since the upgrade to version 9.0.1 of Firefox, the Bookmarks feature changes are confusing me. They seem to be confusing themselves as well. The list of bookmarks has changed. The font size is so small that my aging eyes cannot read it without fogging the screen with my breath. Some folders are out of alphabetical order (where I know they were previously good), and some are missing altogether (folders to which I frequently add references).
    As for missing or deranged files or folders, was there something that I should have done or now need to do to recover those after the upgrade (or before)?
    With regard to font size,
    1. there is no “Edit Bookmarks” or like option to edit the list in this version
    2. the “zoom” option in the “view” list of functions is greyed out when in “Show All Bookmarks” window
    3. expanding the browser window has no effect on font size
    4. “Preferences” settings for font size has no effect in that window either, including advanced settings
    5. “Help” offers none that I can find.
    Can any of you Help?!?

    Maybe this extension helps:
    *Theme Font & Size Changer: https://addons.mozilla.org/firefox/addon/theme-font-size-changer/

  • In InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to

    This may be a basic question... but in InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to determine what word count we can fit in, and c) how to do it in a table? Thanks!

    Set your ruler increments to pixels Preferences>Units & Increments. You can fill the text box with placeholder text Type>Fill with Placeholder text and get a word count from the Info panel with Show Options turned on from the flyout.
    From the Transform panel you can set a text box's width and height

  • How does one create LOV Map between 2 fields for custom lookup mapping

    Hi there
    In Internet Expenses, Expense Report Line Detail we have two unrelated fields; namely Expense Location & Tax Code.
    The requirement is to map a default tax code to locations; basically when a user enters Expense Location then the mapped tax code value should default into field Tax Code.
    The location-tax code mapping is stored in a custom lookup (FND_LOOKUP_VALUES).
    My question is how does one go about implementing this?  For example is it possbile to create a new (hidden) LOV based on the lookup mapping & then create a Personalization LOV Mapping between the 3 LOV...  Or is it necessary to modify the Tax Code drop down Message Choice in JDeveloper?  Of course details are appreciated!
    FYI below is the relevant Personalization Structure from "Personalize Stack Layout: (NormalDetails)".
    Message Lov Input: Expense Location
    - Lov Mappings
    -- Lov Map: (lovMap1)
    -- Lov Map: (lovMap2)
    -- Lov Map: (lovMap3)
    - Message Text Input: Expense Location
    - Message Styled Text: Transaction Location
    - Message Text Input: Merchant Name Yes
    - Message Styled Text: Description
    - Message Check Box: Original Receipt Missing Yes
    - Message Choice: Tax Code
    - Message Check Box: Amount Includes Tax
    - Message Choice: Tax Code
    Many thanks
    G

    Hello all
    The correct & supported method is this:
    Extend the location LOV in JDeveloper & add a "default tax" attribute, this could be derived from a new location DFF storing the default tax code for each location. Now simply create a location Personalization LOV Map which takes this new location lov tax attribute & target it to the tax message choice field.
    That's my 2c worth anyway, so please give comment if you feel there is a better way.
    There is just one more little problem however... The requirement has changed! Now we require the tax code to default according to not one location field, but other fields too. For example if the user selects Expense Type of Beverage & Location of Netherlands then Tax Code should be NL19%, for Expense Type of Hotel then it should be NL6%; if the user ticks "Missing Receipt" field then it should over ride all others & set the code to NL0%.
    Any ideas?
    Many thanks
    G
    Edited by: user13363208 on 11-Aug-2010 06:51

  • How does one rename or even delete templates in Pages?

    How does one rename or even delete templates in Pages?

    At the top of this page, click on your name or avatar to go to your profile page. You need to have more than one product listed in My Products and the one you need to edit can't be set as the default. So, add a product if you only have one & set this second as default. Then back to your profile page where you can edit the settings, including your OS version. Then back again to set this one as default. This is just one of many, many things that the current forum software makes very difficult. I have to go "hunting" for the setting each time, it's that difficult. If I were invited to test changes or a new version, this is one thing I'd mention.

  • How does one access "footers" in Dreamweaver cs6?

    How does one access "footers" in Dreamweaver cs6?

    How does one access "footers" in Dreamweaver cs6?
    Depends on your code.  If your site uses Server-side Includes, it's quite possible the footers are in a separate file in your site folder such as footer.php or footer.incl, or footer.html.
    If that's the case here, you need a local testing server to see them in your parent page.
    Nancy O.

  • How does one get i movie to open . . . the "pinwheel" just keeps spinning

    How does one get i movie to open? The pinwheel is in a perpetual state of spinning.

    Hi,
      mFulErr                       = -41,  /*memory full (open) or file won't fit (load)*/
    At the Apple Icon at top left>About this Mac.
    Then click on More Info>Hardware and report this upto but not including the Serial#...
    Hardware Overview:
    Model Name: iMac
    Model Identifier: iMac7,1
    Processor Name: Intel Core 2 Duo
    Processor Speed: 2.4 GHz
    Number Of Processors: 1
    Total Number Of Cores: 2
    L2 Cache: 4 MB
    Memory: 6 GB
    Bus Speed: 800 MHz
    Boot ROM Version: IM71.007A.B03
    SMC Version (system): 1.21f4

  • How does one perform mailbox to mailbox moving of email messages w/ Messaging 3.X?

    How does one perform mailbox to mailbox moving of email messages with Messaging 3.X?
    <P>
    In an ISP environment there are times that a user changes his
    login name (his unique identifier in the ISP's network, also used as
    his email address) from one value to another. It is very convenient
    for the ISP to be able to move messages from the user's old mailbox
    to the user's new mailbox when this situation occurs.
    <P>
    With Messaging Server 2.0, this was easily accomplished by simply
    moving the mail messages on disk. However, with the added complexity
    of Messaging 3.0 where there are back links, reference counts, etc.,
    associated with mail messages, moving files on disk from one mailbox
    to another is no longer valid.
    <P>
    The MoveUser utility, which is new in MS 3.X, moves messages from
    one messaging server to another or from one maildrop path to another.
    Can this utility be used to move messages from one mailbox to another?
    <P>
    The answer is yes, it can. The user should be aware that if
    duplicate email message id's exist in the mailbox before the
    move, the messages related to the duplicate message id's will
    be duplicated in the target mailbox.
    <P>
    See the online documentation contained with the product or the
    Messaging 3.X Administrator's Guide for exact syntax.

    Hi
    If I understand you correctly and if you are using Apple Mail version 2.0 or above navigate to /Users/Home folder. The Home folder is the one with the house icon, within that folder you will see a Library folder, within that folder you’ll see a Mail folder, within that folder you’ll see a folder that begins with POP followed by your name, within that folder will be a folder called INBOX.mbox, within that folder is a Messages folder. All the mail that you see within the application are there. They will be numbered and have a file suffix of .emlx. You can move these wherever you like.
    If you are using Entourage X, or Entourage 2004 you can easily multiple select mail messages, addresses etc from within the application and drag whatever you’ve selected to wherever you like.
    Tony

  • ACE: How does one probe "rservers redirect" in "serverfarm redirect"?

    Probes can be used with serverfarms of type host
    probe http WEB_SERVERS
    interval 5
    passdetect interval 10
    passdetect count 2
    request method get url /index.html   expect status 200 200
      !--- Probe used to detect the status  !--- of the servers in the serverfarm.
    rserver host S1
    ip address 192.168.0.200
    inservice
    rserver host S2
      ip address 192.168.0.201
      inservice
    rserver host S3
      ip address 192.168.0.202
      inservice
    rserver host S4
      ip address 192.168.0.203
      inservice
    serverfarm host SF-1
      probe WEB_SERVERS
      rserver S1
       inservice
      rserver S2
       inservice
      rserver S3
       inservice
      rserver S4
       inservice
    When it comes to "serverfarm redirect" how would one emulate the probing to work as above. (When one is loadbalancing servers of type redirect, the probe command is not available for serverfarm redirect SF-2)
    Its also not possible to mix reservers of type redirect with serverfarm of host. If it was possible, This would have answered my question, which is.
    How does one emulate the probe functionality found in rsever host and serverfarm host in serverfarm redirect?

    Probing a redirect server was supported on A2(3.2) or later.
    So, you can use the probe configuration on 'serverfarm redirect', where 'ip address [ip_address] routed' option is required.
    http://www.cisco.com/en/US/docs/interfaces_modules/services_modules/ace/vA2_3_x/Release/Note/RACEA2_3_X.html#wp620109
    Unfortunately, 'rserver host' and 'rserver redirect' cannot exist together in the same serverfarm since 'serverfarm host' is
    for real server and 'serverfarm redirect' is for redirect rserver.
    http://www.cisco.com/en/US/docs/interfaces_modules/services_modules/ace/vA2_3_0/command/reference/config.html#wp1117844
    When you use backup serverfarm as below, you can use both serverfarms. However, you cannot use primary serverfarm
    and backup serverfarm at the same time.
    policy-map type loadbalance first-match lb
      class class-default
        serverfarm SF1 backup SF2
    Regards,
    Yuji

  • How does one email a video from iPhoto

    how does one email a video from iPhoto

    One doesn't.
    Simply, sharing video via email is not advisable.
    Many email services have an attachment limit of 20mb and some a limit of 10mb. As emails are sent through an array of relays, the effective limit is the smallest file size allowed on any of the relays.  That means that video is rarely suitable for emailing.
    Then there's the whole issue of Codecs and not all machines will have the codecs to play all videos. Plus, folks with slower connections can find it very inconvenient to download large video files.
    Finally, sharing video from iPhoto via email is not supported. All that gets you is the Movie thumbnail. If you feel you must share via email then you'll need to export the video first, and attach that. Use the File -> Export command and set the kind  to Original.
    This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.
    Other than that your options include:
    Upload it to a sharing site like YouTube or Vimeo and email a link - these will allow the recipient to view the material online. That will avoid the codec issues mentioned, and the person can still download the video file if they wish.
    Upload it to sharing services like Dropbox or YouSendIt and email a link. This will require that they download the material to their machines to view.
    Regards
    TD

  • HT1212 my niece lockup her ipod and don't remember password and/or it dont work now   there no access to setting to wipe and reformat  how does one do this

    How does one redo a 8GB ipod?  My neice has one and lock it with a password and now password dosen't work and/or she forgot it!  It give message ipod is diable!  connect to Itunes!  I've done that and the device doesn't showup in itunes, keep getting a message that password is needed!  But there no input for that on the phone either!  So I thought I would just dump and reformat and reinstall software, but I'm using windows and the device dosen't show up! Anyone!!!!! got a answer!
    Thanks

    Disabled
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

Maybe you are looking for

  • MacBook Pro getting hot quickly

    I bought a MacBook Pro in November, and it seems to get hot very quickly. It is usually just sitting on a desk. It sounds like the fan is working, but I don't know a solution. I have a Speck case on it, but I don't think that would be an issue? Is th

  • Import files into iTunes song title is truncated

    When importing files using the "File - Add File To Library" function for songs with very long title names, the song title is being truncated at about 35 characters upon import into Itunes. Is there a way to stop this from happening?

  • PSE 8 Hilfe in Menueleiste ist nicht benutzbar

    Wenn ich in Photoshop Elements 8 die Hilfe verwenden möchte, um etwas zu erfragen, so stürzt das Programm immer ab. Sonst scheint das PSE 8, gekauft am 1.2.2010, zu funktionieren.  Wie kann ich das beheben?  Habe mit Neuinstallieren versucht, bringt

  • My ipad sound doesn't work?

    My ipad sound does not work, only when I put head phones in or using FaceTime.. Event if I use my head phone the sound is in and out. It's not locked on silent or anything. It's just not working, not my apps, music or videos. My ipad will just be com

  • Question abotu String.format() functionality

    Hello all, I am curious as to whether this functionality exists in the String.format method, or if there is any other class in the current version of Java that would allow for this. I want to construct a format string, where if one of the args contai