Transferred code from PC to MAC - PrintWriter NOT working

Hey guys,
I wrote a script which created a JFrame with a few buttons on my PC and had everything working nicely. The toggle button (after it's released) is supposed to output a .txt file with a few lines of data on it, but no longer works on my MAC. It's also interesting that the .setBackground() function (where I change their displayed color) no longer works either yet the setEnabled() command still does (both are under ActionListener instances).. There are no errors on my script and I'm curious to know what is going on.
Here is my code:
import javax.swing.*;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.Long;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
public class Button  {
     protected JToggleButton jtb;
     protected JButton jbL;
     protected JButton jbR;
     protected JTextField jtext;
     public static ArrayList<Integer> goodSegments = new ArrayList<Integer>();
     public static ArrayList<Integer> badSegments = new ArrayList<Integer>();
     public static Integer initSpeech,endSpeech;
     public Integer timeStart,timeEnd;
     public String badgeNumber;
     ActionListener toggle = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
               if (jtb.isSelected()) {
                    jbL.setEnabled(true);
                    jbR.setEnabled(true);
                    initSpeech = toInteger(System.currentTimeMillis());     
                    jtb.setLabel("Processing...");
                    jtb.setBackground(Color.white);
               else {
                    jbL.setEnabled(false);
                    jbR.setEnabled(false);
                    endSpeech = toInteger(System.currentTimeMillis());
                    try {
                         outputTXT();
                    } catch (IOException e1) {
                         e1.printStackTrace();
                    jtb.setFont(new Font("Sanserif", Font.BOLD,12));
                    jtb.setLabel("SPEECH OVER");
     ActionListener left = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
               if (jtb.isSelected()) {
                    if ("recording good".equals(e.getActionCommand()) && jbR.isEnabled()) {
                         jbR.setEnabled(false);
                         timeStart = toInteger(System.currentTimeMillis());
                         jbL.setBackground(Color.GREEN);
                    else if ("recording good".equals(e.getActionCommand()) && !jbR.isEnabled()) {
                         jbR.setEnabled(true);
                         timeEnd = toInteger(System.currentTimeMillis());
                         goodSegments.add(timeStart);
                         goodSegments.add(timeEnd);
                         jbL.setBackground(null);
     ActionListener right = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
               if (jtb.isSelected()) {
                    if ("recording bad".equals(e.getActionCommand()) && jbL.isEnabled()) {
                         jbL.setEnabled(false);
                         timeStart = toInteger(System.currentTimeMillis());
                         jbR.setBackground(Color.RED);
                    else if ("recording bad".equals(e.getActionCommand()) && !jbL.isEnabled()) {
                         jbL.setEnabled(true);
                         timeEnd = toInteger(System.currentTimeMillis());
                         badSegments.add(timeStart);
                         badSegments.add(timeEnd);
                         jbR.setBackground(null);
     ActionListener text = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
               jtext.selectAll();
               badgeNumber = jtext.getText();
     public Button() {
          /// Setting left (good) button properties
          jbL = new JButton("Good Segment");
          jbL.setHorizontalTextPosition(AbstractButton.LEADING);
          jbL.setActionCommand("recording good");
          jbL.setEnabled(false);
          jbL.addActionListener(left);
          /// Setting right (bad) button properties
          jbR = new JButton("Bad Segment");
          jbR.setHorizontalTextPosition(AbstractButton.LEADING);
          jbR.setActionCommand("recording bad");
          jbR.setEnabled(false);
          jbR.addActionListener(right);
          /// Setting Middle (toggle) button properties
          jtb = new JToggleButton("Begin Recording");
          jtb.setEnabled(true);
          jtb.addActionListener(toggle);
          /// Setting Text Field properties
          jtext = new JTextField("Please Enter Badge Number");
          jtext.setEditable(true);
          jtext.addActionListener(text);
     public Integer toInteger(long l) {
          Long a = new Long(l);
          Integer i = new Integer(a.intValue());
          return i;
     public void outputTXT() throws IOException {
          PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter("badge-"+badgeNumber+".txt")));
          file.write(badgeNumber.toString());
          file.println();          
          file.write(initSpeech.toString());
          file.println();
          file.write(endSpeech.toString());
          file.println();
          if (goodSegments.size() != 0)
          for (int i=0;i<goodSegments.size();i++) {
               file.write(goodSegments.get(i).toString());
               file.println();
          file.write(new Integer(0000).toString());
          file.println();
          for (int i=0;i<badSegments.size();i++) {
               file.write(badSegments.get(i).toString());
               file.println();
          file.close();
    public static void main(String[] args) {
         JFrame jframe = new JFrame();
         Button b = new Button();
        Container cp = jframe.getContentPane();
        cp.setLayout(new FlowLayout());
        cp.add(b.jbL);
        cp.add(b.jbR);
        cp.add(b.jtb);
        cp.add(b.jtext);
        jframe.pack();
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jframe.setVisible(true);
}Thanks Guys!

You might consider explaining what "not working" means.

Similar Messages

  • Transferred music from PC to Mac will not load on iPod

    I'm new to Mac's--have a G5; I used my iPod as hard disk to transfer my itunes library from a PC to the Mac; this list shows up in the Source list but not as my Library, it's designated with a music note symbol-in blue-with a ejection symbol (like the ejection symbol you see next to my iPod symbol in the source list); I can play the tracks--but am unable to drag tracks to a new playlist or download them to the iPod; I've spent untold hours trying to correct this updating preferences, etc...everything thing I've read so far does not match my scenario---does anyone out there have a suggestion on how I can correc this. I've got approx 500 songs that I am unable to use! Help is much appreciated!
    Yvonne

    You might consider explaining what "not working" means.

  • Transfering docs from iPad to Mac doesn't work

    I have 2 iPads: iPad 1 and iPad 2. I bought iPad 2 a month ago and –using Snow Leopard– I could
    transfer all my documents from iPad 1 to my Mac. After that, I loaded my new iPad 2 with the same
    documents from Mac. I have updated to Lion and to iTunes 10.4 but now I see that I can't transfer
    the documents from my iPads. For example, when selecting GoodReader, I can see only a partial
    list of documents (in both iPads), so I could never transfer the whole set of documents. There is now
    another problem: I selected this partial list of documents in order to transfer them to Mac, but when
    the transfer process detect a folder, the transfer stops indicating an error. In the following figure,
    BPM-SOA is just a folder, and it only says "an error is produced" and "the file is not found" without further information.
    I deduce this problem is relatied with Lion/iTunes 10.4 as the same iPad 1 from which I tranfered all
    my documents, now it only shows the partial list of documents (ending in NUI Natural User...) but I
    have documents whose names begin with 'Z'. So, the set of documents between N and Z dissapeared
    while when I transfered all the documents with Snow Leopard and iTunes 10.3 all worked fine and I have
    a folder with the complete list of documents. I have a MacBook aluminiun, 13'' , 2 Gz Intel Core 2 duo, 4 Gb RAM,
    an iPad 1 wifi 32 Gb and an iPad 2 wifi 64 Gb.

    the GoodReaderUSB tool allows you to transfer entire folders into GoodReader without loosing the folder/file structure. also you can do the same in reverse using the tool. ie transfer everything from your iPad back onto your desktop.
    Windows: http://www.goodiware.com/usb/GoodReaderUSBWin_200.zip
    Mac: http://www.goodiware.com/usb/GoodReaderUSBMac_202.zip
    also, I'm not affiliated with this tool in anyway, its just very very useful.

  • I have problems transferring files from PC to Mac and from Mac to Mac

    I have problems transferring files from PC to Mac, and from Mac to Mac.  PC to PC is fine.  Nothing but problems with the Mac.  One example:
    While working on my PC, I open shared folders on an external HDD connected to the Mac.  I click on paste to move the files.  I get an error after a few seconds to a minute of trying to move several files from my PC Win 7 to Mac OS Maverick, that there is a file already at the destination on Mac. This statement is true, but it was just put there because I am copying them over in that same action.  It reads 0Kb and wasn't there before I started.  Then I get an error: The Action Cannot be completed because the folder is open in another program.  Close the folder or file and try again..
    Whether I click on it a bunch right of way or wait, it still takes about 45 seconds. I have to do it with every file and it only happens when copying from a PC to Mac.  I have even restarted both computers so nothing is using any files.  If I copy one file at a time, I don't get any error.
    So I have one file to move, no problem.  If move 5 files, The first will go fine, but it shows all 5 files in folder at once.  All other files than the first show 0kb. I get the file already existing error once it starts the second file transfer, and I select move and replace.  Then I get The Action Cannot be completed because the folder is open in another program.  I wait or click repeatedly until it starts to move file.  That file will then show something other than 0kb.  When it is done, the error process starts all over.  I tried checking the PC with unlocker, but the files do not show themselves locked on the PC.

    Its not only French. Even certain characters in English will come across as gobblydegook from 1 platform to another. I see this in emails that likely were composed in Word & the characters don't come across.
    Not sure if this is still true, but years ago someone explained that there is a standard character set & then I think its extended characters & those vary from platform to platform or language to language, etc.

  • I transfered data from my old Mac, but now it tells me "No Access" when I try to open the files. How can I fix that?

    I transfered data from my old Mac, but now it tells me "No Access" when I try to open the files. How can I fix that?

    That's the problem, then. The files are under your 'old' user account. You should be able to access them if you log into your old account. However, that's not going to let you move them to your new user account. It's for situations like this that I always create a root user account (although I seldom access it). With a root user account, you can copy files from one user account to another. Note that someone may come up with a better idea than what I would use, but here goes.
    Read http://support.apple.com/kb/ht1528 and set up a root user. Then you can transfer files from one account to another. If you like, you can delete this account after you've moved your files.
    Good luck,
    Clinton

  • I have recently transferred data from my old Mac to my new one. The result was good, but I have 2 users now, whose data I want to merge into 1 single user, so to avoid having to switch from one user to the other to view and use certain files. How to do it

    I have recently transferred data from my old Mac to my new one. The result was good, but I have 2 users now, whose data I want to merge into 1 single user, so to avoid having to switch from one user to the other to view and use certain files. How to do it?

    Here's an easy way:
    Pick the user that you want to eliminate (making sure that the remaining user has administrator privileges) and move all of the data that you want to keep into the Shared folder. Reboot or log out and login to the user you want to keep. Copy all the data from the Shared folder into your account - placing it neatly in folders (Documents, Music, Movies, etc.).
    Once the data is moved, log into the account you want to delete just once more to make certain that you've grabbed all the data you want to keep. Log out and log back into your admin account and go to System Preferences>Users & Groups and delete the 'old' user.
    That should do it.
    Clinton

  • How do i transferring video from iphone to mac

    how do i transferring video from iphone to mac, i synced it but nothing shows up

    I don't believe OS X has the ability to receive AirPlay (which is what you're using).  There's some advice on the matter on the Wikipedia page, though:
    http://en.wikipedia.org/wiki/AirTunes
    Scroll down to "Third-party software implementations".

  • Accidentally removed from,sharing and permissions the admin user,and now i do not when i find the home icon at my computer i do not have permmission,and the mac does not works properly,lots of question mark at the dock ,please help

    accidentally removed from,sharing and permissions the admin user,and now i do not when i find the home icon at my computer i do not have permmission,and the mac does not works properly,lots of question mark at the dock ,please help

    I'm going to assume that since you deleted your hard drive and all its files, you had a backup, yes? If the backup has an OS (bootable clone), then you can boot into it by holding down the option key when you start up you iMac and choose the backup drive. Then use Carbon Copy Cloner or Super Duper to copy the files back to your iMac.

  • Having transferred songs from my old mac to my new Macbook I cannot authorise them because my old Apple ID is an obsolete email account. I cannot retrieve messages from it so cannot change password.

    Having transferred songs from my old mac to my new Macbook I cannot authorise them because my old Apple ID is an obsolete email account. I cannot retrieve messages from the email account it so cannot recieve a password change notification. The answers I give to security question is rejected. Help!

    Contact iTunes Customer Service and request assistance with your issue...
    Apple  Support  iTunes Store  Contact Us

  • Why copy option from recent call numbers is not working on ios7 [recent call logs in phone]?

    why copy option from recent call numbers is not working on ios7 [recent call logs in phone]?

    Here is a copy of my expressions and a copy of my data. The expressions match up going from left to right
    Code.CalcPTD2(Lookupset(FORMAT(Fields!REALDATE.Value,"Long Date"),FORMAT(Fields!CallbackDate.Value,"Long Date"),Fields!DailyHours.Value,"DataSet4"))
    sum(Code.CalcPTD2(Lookupset(FORMAT(Fields!REALDATE.Value,"Long Date"),FORMAT(Fields!CallbackDate.Value,"Long Date"),Fields!DailyHours.Value,"DataSet4")))
    count(Code.CalcPTD2(Lookupset(FORMAT(Fields!REALDATE.Value,"Long Date"),FORMAT(Fields!CallbackDate.Value,"Long Date"),Fields!DailyHours.Value,"DataSet4")))
    PUBLIC SHARED FUNCTION CalcPTD2(LookupArray AS OBJECT) AS INTEGER
         DIM i,Total AS INTEGER
         Total = 0
         FOR i = 0 to UBOUND(LookupArray)
               Total = Total + CINT(LookupArray(i))
         NEXT i
     NumberTimes  =   NumberTimes +1
    RETURN  Total
    END FUNCTION

  • Installing Java 7 from Oracle just made Applets not work, how to fix

    Mac 10.7.4. I tried installing Java 7 from Oracle, but all it did was remove half the prefs from Java and make Applets not work. How do I revert/reinstall Java?

    Here you go!
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • I have redemption code from 500px but it does't work because of country of account doesn't match the country of the code  , they gave me another one and does't work also because something is wrong and try again?

    I have redemption code from 500px but it does’t work because of country of account doesn't match the country of the code  , they gave me another one and does’t work also because something is wrong and try again?

    creative cloud abo from 500px does not work with german Adobe ID!! What can I do? has the email address for 500px (for anyone else reading this message) and a note saying that 500px has a fix... so you might try writing to 500px again

  • HT5622 my apple id is not working when i sign in from my laptop it works but when i sign in from my iphone4 then its not working it gives the message of "your aapleid or password is incorrect"? how can i solve this problem please help

    my apple id is not working when i sign in from my laptop it works but when i sign in from my iphone4 then its not working it gives the message of "your aapleid or password is incorrect"? how can i solve this problem please help

    Hey nocillado,
    Thanks for using Apple Support Communities.
    It sounds like you have 2 things you want to address. These articles can help you use iCloud with your existing Apple ID.
    Get help activating your iPhone
    http://support.apple.com/kb/ts3424
    Using your Apple ID for Apple services
    http://support.apple.com/kb/ht4895
    Using the same Apple ID for Store purchases and iCloud (recommended)
    Have a nice day,
    Mario

  • BIP report security from Dashboard to Publisher is not working

    Hi ,
    I created a BIP report(.xdo) and placed it on Dashboard as a link . As admin , I can see the report . As a user , I am able to get into publisher but not able to see the report . Iam getting the below error message .
    Error : Unauthorized Access: please contact the administrator.
    I suspect that security model from Dashboard through BIP is not working . I tried searching the online resources but couldnt find right help .
    Iam a newbie for BIP , I followed the regular BIP guides , configured eveything as per the docs and things work as admin . But I want to test the security as user .
    Where Iam doing wrong , Any ideas please help .
    Thanks
    Karthik

    Hello Vijay ,
    I have grant permissions to the user and the report in BI webcatalog and also in BIP under admin tab I have addes the role which the user belongs to and also the shared folder . Still the problem exists.
    My BI presentation servcies security is working . My user security is also working , all that I need is the user should be able to see the report when he clicks on BIP link placed in dashboard.

  • I have an iMac with OS Lion. The Smartart feature for Office for Mac will not work when I am logged on to my personal user account. It works with other user accounts on the same computer, and it works after "safe start". How can I fix the problem?

    The Smartart feature of Office for Mac will not work in my user account. It works for all other user accounts on the same computer, and it works after a "safe start". How can I fix the problem?

    You may also want to search/ask in the forums run by the people who make the product which is causing you problems:
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011

Maybe you are looking for