Help!! cant get the button to make the calculation take place

hi, im kinda new at this
im trying to create a download program, and am unable to make it so that the damn answer will work. any ideas of what im doing wrong?? heres my code:
//by Brett Kennelly
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
public class Download implements ActionListener {
     boolean start = false;
     JLabel label;
     JButton calcButton;
     JPanel pane, radioPanel;
     JFrame frame;
     JTextField filesize, speed, alreadydl;
     String kilobytes = "kilobytes";
     String bytes = "bytes";
     String megabytes = "megabytes";
public Download() {
     // create the widgets
          // creates the radio buttons
          JRadioButton kiloButton = new JRadioButton(kilobytes);
          kiloButton.setActionCommand(kilobytes);
          JRadioButton byteButton = new JRadioButton(bytes);
          byteButton.setActionCommand(bytes);
          JRadioButton megaButton = new JRadioButton(megabytes);
          megaButton.setActionCommand(megabytes);
          megaButton.setSelected(true);
          // calculation button created
          calcButton = new JButton("Calculate");
          calcButton.addActionListener(this);
          calcButton.setActionCommand("calc");
          // label displaying answer created
     label = new JLabel("No button pressed", SwingConstants.CENTER);
          // create the text fields
          filesize = new JTextField(2);
          speed = new JTextField(2);
          alreadydl = new JTextField(2);
          // add components to panel
     pane = new JPanel();
          pane.setLayout(new GridLayout(0, 2));
     pane.add(calcButton);
     pane.add(label);
          pane.add(filesize);
          pane.add(speed);
          pane.add(alreadydl);
          // groups the radio buttons
          ButtonGroup group = new ButtonGroup();
          group.add(byteButton);
          group.add(kiloButton);
          group.add(megaButton);
          // Register a listener for the radio buttons.
     RadioListener myListener = new RadioListener();
     byteButton.addActionListener(myListener);
     kiloButton.addActionListener(myListener);
     megaButton.addActionListener(myListener);
          // panel holding radio buttons is created
          radioPanel = new JPanel();
          radioPanel.setLayout(new GridLayout(0,1));
          radioPanel.add(byteButton);
          radioPanel.add(kiloButton);
          radioPanel.add(megaButton);
          // create the top-level container
     frame = new JFrame("Download");
     frame.getContentPane().add(pane, BorderLayout.WEST);
          frame.getContentPane().add(radioPanel, BorderLayout.CENTER);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
     frame.setVisible(true);
class RadioListener implements ActionListener {
     public void actionPerformed(ActionEvent e) {
               String command = e.getActionCommand();
                    DecimalFormat df1 = new DecimalFormat("##.00");
                    // values of the contents of the text fields recieved and implemented into thier according equation
                    double totalsize = (double)(Double.parseDouble(filesize.getText()));
                    double speedofdl = (double)(Double.parseDouble(speed.getText()));
                    double alreadydled = (double)(Double.parseDouble(alreadydl.getText()));
               if(command=="bytes") {double actualsize = totalsize - alreadydled;
                    double inkb = actualsize / 1024.000;
                    double files = inkb / speedofdl;
                    double finalnum = files / 60.000 / 60.000;
               label.setText(df1.format(finalnum) + (" Hours to go!"));}
               if(command=="kilobytes") {double actualsize = totalsize - alreadydled;
                    double files = actualsize / speedofdl;
                    double finalnum = files / 60.000 / 60.000;
               label.setText(df1.format(finalnum) + (" Hours to go!"));}
               if(command=="megabytes") {double actualsize = totalsize - alreadydled;
                    double inkb =  actualsize * 1024.000;
                    double files = inkb / speedofdl;
                    double finalnum = files / 60.000 / 60.000;
               label.setText(df1.format(finalnum) + (" Hours to go!"));}
     public static void main(String[] args) {
          Download app = new Download();
thanks.

hi, ive completely (or practicaly) redone the code, and narrowed it down to one error:
Download.java:58 illegal start of expression
public void actionPerformed(ActionEvent e) {
and heres the new code:
//by Brett Kennelly
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
public class Download implements ActionListener {
     boolean start = false;
     JLabel label;
     JButton calcButton;
     JPanel pane, radioPanel;
     JFrame frame;
     JTextField filesize, speed, alreadydl;
     String kilobytes = "kilobytes";
     String bytes = "bytes";
     String megabytes = "megabytes";
     public Download() {
          // create the widgets
          // calculation button created
          calcButton = new JButton("Calculate");
          calcButton.addActionListener(this);
          calcButton.setActionCommand("calc");
          // label displaying answer created
     label = new JLabel("No button pressed", SwingConstants.CENTER);
          // create the text fields
          filesize = new JTextField(2);
          speed = new JTextField(2);
          alreadydl = new JTextField(2);
          // add components to panel
     pane = new JPanel();
          pane.setLayout(new GridLayout(0, 2));
     pane.add(calcButton);
     pane.add(label);
          pane.add(filesize);
          pane.add(speed);
          pane.add(alreadydl);
          // create the top-level container
     frame = new JFrame("Download");
     frame.getContentPane().add(pane, BorderLayout.WEST);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
     frame.setVisible(true);
                    public void actionPerformed(ActionEvent e) {
                    String command = e.getActionCommand();
                    if(command="calc") {start = true;
                        Download.RadioB();}
               public RadioB() implements ActionListener {
                    // creates the radio buttons
                    JRadioButton kiloButton = new JRadioButton(kilobytes);
                    kiloButton.setActionCommand(kilobytes);
                    JRadioButton byteButton = new JRadioButton(bytes);
                    byteButton.setActionCommand(bytes);
                    JRadioButton megaButton = new JRadioButton(megabytes);
                    megaButton.setActionCommand(megabytes);
                    megaButton.setSelected(true);
                    // groups the radio buttons
                    ButtonGroup group = new ButtonGroup();
                    group.add(byteButton);
                    group.add(kiloButton);
                    group.add(megaButton);
                    // panel holding radio buttons is created
                    radioPanel = new JPanel();
                    radioPanel.setLayout(new GridLayout(0,1));
                    radioPanel.add(byteButton);
                    radioPanel.add(kiloButton);
                    radioPanel.add(megaButton);
                    frame.getContentPane().add(radioPanel, BorderLayout.CENTER);
               if(start=true) {
          public void actionPerformed(ActionEvent e) {
               String command2 = e.getActionCommand();
               DecimalFormat df1 = new DecimalFormat("##.00");
               // values of the contents of the text fields recieved and implemented into thier according equation
               double totalsize = (double)(Double.parseDouble(filesize.getText()));
               double speedofdl = (double)(Double.parseDouble(speed.getText()));
               double alreadydled = (double)(Double.parseDouble(alreadydl.getText()));
               if(command==bytes) {double actualsize = totalsize - alreadydled;
                    double inkb = actualsize / 1024.000;
                    double files = inkb / speedofdl;
                    double finalnum = files / 60.000 / 60.000;
               label.setText(df1.format(finalnum) + (" Hours to go!"));}
               if(command==kilobytes)) {double actualsize = totalsize - alreadydled;
                    double files = actualsize / speedofdl;
                    double finalnum = files / 60.000 / 60.000;
               label.setText(df1.format(finalnum) + (" Hours to go!"));}
               if(command==megabytes) {double actualsize = totalsize - alreadydled;
                    double inkb =  actualsize * 1024.000;
                    double files = inkb / speedofdl;
                    double finalnum = files / 60.000 / 60.000;
               label.setText(df1.format(finalnum) + (" Hours to go!"));}
          public void actionPerformed(ActionEvent e) {};
     public static void main(String[] args) {
          Download app = new Download();
any help would be great thanks

Similar Messages

  • CPROJECTS - How does the calculation take place ?

    Hi,
    I am wokring in cprojects. I have done the following entries
    <u><b>cost revenue rate - defined</b></u>
    amount costs - 50 US dollars /Hrs
    amount revenue 10 US dollars/Hrs
    different revenue - 1.0 US dollars / Hrs.
    <b><u>resource assigned and staffed for 20 hrs</u></b>
    <u><b>After calculate costs the value shown are</b></u>
    proj defn -
    20 hrs----
    costs 89.80 USD
    projet role -
    20 hrs -
    costs 39.80 USD
    responsilbe person - 20hrs - costs 39.80 USD
    Can anyone please explain me how this calculation takes place in cprojects 3.1.
    Please do the needful
    Regards,
    Amit

    Hi Amit,
    don't understand how this calculation result can be caused. In general it should be:
    for a role: (hours - hours already assigned to resource) * role rate
    + hours assigned to resource * resource rate (is assigned in the business partner)
    Regards,
    Thorsten

  • My volume button seems stuck,i cant get the volume to go up,any ideas?

    ON my ipad2 the volume button is stuck,i cant get the volume to go up.any ideas?

    Thanks for the link ..so far I was only able to acces the utility disk, it says my disk needs repair but while attempting to repair it I get the following: Invalid record count...Any ideas on what should I try next????
    I appreciate your help!

  • I need help setting up an apple id for my sons phone. It seems his email address has been taken and/or we cant get the password.

    I need help setting up an apple id for my son's phone. It seems his email address has been taken and/or we cant get the password.

    Two different things
    If you forgot the password
    If you forgot your Apple ID password - Apple Support
    If the email ID you want to use is in use by someone else - then you may need a new one
    The iCloud ID's are usually unique and may be of help if you set one up

  • HT4859 I have the error message "Not enough storage. Cannot backup, not enough backup space in ICloud . . . ", but now the "close" and "settings" buttons don't respond and I cant get the IPad to open so I can go change settings. What do I do?

    I have the error message "Not enough storage. Cannot backup, not enough backup space in ICloud . . . ", but now the "close" and "settings" buttons don't respond and I cant get the IPad to open so I can go change settings. What do I do?

    For a "hard" restart of your iPad just press the home and power button at the same time and hold it for at least 10-15 sec. until it restarts.

  • TS5183 I cant get the little talking microphone on my phone to speak into for messages and e mail can you help please!

    I cant get the little microphone symbol on keyboard of my i phone, was there before I changed the case

    Hello Sugarduke
    Check to make sure that Siri is turned on in Settings > General > Siri, and you should be able to start using the Dictation feature on your iPhone.
    iOS: About Siri
    http://support.apple.com/kb/ht4992
    Regards,
    -Norm G.

  • I cant get the letter A and number 1 to work on my ipod  touch screen can you help me

    i cant get the letter A and nimber 1 to work on my touch screen on my ipod to work.

    Try the stand fixes, one at a time:
    - Reset:
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    - Restore the iPod from backup
    - Restore the iPod to factory defaults/new iPod.

  • My Creative Cam wont work properly in MSN Messenger! I cant get the effects to work PLEASE HELP!

    When I open the webcam centre everything works fine I can get all the effects...BUT when I open messenger (MSN) I get a good picture but when I open the effects window I cant get the effects to work in there.... I went to the creative site which tells me I can use this cam ok in MSN Messenger....Please help before I pull my hair outThankyouBillie-Jean x

    I had the exact same issue but finally after much reading found that the Advanced Video FX utility must be activated first, then open the Web Cam Center.
    On the upper left side just above your image is a Device Selection box. You may not redily recognize it as such.. Click on the down arrow just to the left of the Format tab and select the "Creative WebCam(With Video Effects)". Now try the effects. This did the trick for me. Hope it works for you!

  • Won't open, uninstalled, but now cant get the installer to reinstall. help!

    PS refused to open and advised an uninstall. DONE.
    now cant get the installer to recognise that it has been uninstalled and reinstall

    Are you talking about Photoshop CC?  If you are wanting to get CC to know you’ve uninstalled Photoshop, then Quit the CC Desktop app, then restart it—this causes it to rescan what is installed, and at that point it should show an Install button next to Photoshop.
    And if that doesn't work there are more things to try:
    http://helpx.adobe.com/creative-cloud/kb/aam-lists-removed-apps-date.html

  • Lightroom,Cant get the permanent delete button for pictures.

    On Lightroom4+5 I try to remove some of my pictures permanently, cant get the window with the tree delete buttons. I use a Mac. It must be a simle thing...but i fell over this one a few times...

    Switch to folder view, grid mode (or if not grid mode, context menu of selected photos in filmstrip).
    If you want to permanently delete pictures whilst viewing a collection, consider splat-delete instead:
    Windows: Ctrl-Shift-Alt-Delete
    Mac: Cmd-Shift-Option-Delete
    *** Beware: There will be NO prompt.
    Rob

  • I cant get the font to work on a picture in Photoshop, I have watched at least 12 how to videos and it wont work, Help

    I cant get the font to work on a picture in Photoshop, I have watched at least 12 how to videos and it wont work, Help

    Could you capture your screen and post it. Have the layers panel open and any layers that are collapsed, expanded. We will need to see the entire screen, as some information in the tab is important as well.

  • I changed a few settings and now cant get the iPad to shut off with the shut off switch and can't back to the settings icon to change it back. Any ideas?

    I changed a few settings on my iPad and now cant get the iPad to shut off with the shutoff button and the button to get to all the icons won't let me get back to settings to change the settings back.  Can anyone help?

    Have you tried resetting your iPad?
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10-15 seconds).
    No data will be lost.

  • I cant get the phone to turn back on

    i just tried a phone reset by holding home and power button for ten seconds or so and now i cant get the phone turned back on. can anybody help

    Try the troubleshooting help here.  http://www.apple.com/support/iphone/assistant/phone/
    You may need to restore your iPhone.
    If it won't restore, try here. http://support.apple.com/kb/ht1808
    If nothing helps, you need to contact Verizon for information for an exchange or refund. This is a user to user forum, not Apple.
    Apple's policy for a refund or exchange is within 14 days of purchase. Verizon's policy may be different.
    Definitely try restoring .. hopefully you won't have to go through the hassle of an exchange.

  • Hi, I have a late 2011 MacBook Pro but cant get the mirroring function to work with Apple TV.  I've got the most recent Software 10.7.5 but cant see the mirroring icon or turn this on.  I'm able to mirror from my Ipad but not my Mac, any thoughts?

    Hi, I have a late 2011 MacBook Pro but cant get the mirroring function to work with Apple TV.  I've got the most recent Software 10.7.5 but cant see the mirroring icon or turn this on.  I'm able to mirror from my Ipad but not my Mac, any thoughts?

    Welcome to the Apple Support Communities
    AirPlay Mirroring is supported on your Mac, but it needs OS X Mountain Lion (10.8). See > http://support.apple.com/kb/HT5404
    You have two possibilities:
    1. Make a backup, open App Store and purchase Mountain Lion to upgrade to this OS X. Then, you will find the AirPlay Mirroring icon at the top right of the display, on the menu bar, or on System Preferences > Displays.
    2. Keep OS X Lion and use AirParrot > http://www.airparrot.com
    Both options work properly, but I recommend AirPlay Mirroring as it doesn't need a third-party program

  • HT204291 cant get the airplay icon on my iphone 4.

    I've tried all recommendations in troublshooting but still cant get the airplay icon on my iphone4, I can use the remote app, so its definately connected, any ideas?

    Responses can only be as helpful as the details provided.  What are you trying to setup an AirPlay connection to?  Did you enable AirPlay on that device(s) and create an Id?  Did you enter that id into your iPhone?  Did you do any of the steps to setup AirPlay? 
    And the Remote app using HomeSharing which only connects to iTunes and iTunes connects to the other devices.  It has nothing to do with AirPlay.  So that does not really mean anything.

Maybe you are looking for

  • OWB Process/Workflow in third party Workflow engines

    Have any of you had experience using the XPDL file generated by the Process flow component of OWB to execute the Workflow in non-oracle Commercial and/or Open source Workflow engines? If so I'd like to hear about it. I'm attempting to do the same and

  • F-92 posting error- Cost centre locked for revenue posting

    Hello, While I am trying to post F-92 (Asset Retirment), I get the following error: "Cost center AR011001 in controlling area 1000 is locked for revenue postings on 25.11.2009." How do I go ahead? Thanks,

  • Badi/User-Exits for VF01

    Hi expert’s, I need to find a User-Exit or a BADI in transaction VF01 or VF02, I have found several but I need one  “before save” or “after save”. Anyone knows any User-Exit or Badi for this case? Thanks in advance Nuno Rodrigues

  • Join ERP Systems

    Hi, I am not sure whether this is the right area to ask this question, but giving it a try. 1. I have 3 or more SAP HR systems which have got employees and different services in them. 2. Now I want to move all the data to either one of them (meaning

  • ABA_PLUS ADD ON

    Dear all, I having hard time in searching for ADD ON for ABA_PLUS for R/3  Enterprise  4.7 Ext. 1.1. I checked other system like R/3  Enterprise  4.7 Ext. 200 is already contained the ABA_PLUS. Is that possible i copy the ABA_PLUS software compenent