In need of serious JFrame/Stringbuffer Help!

Basicly, it opens a GUI with a few buttons like "previous, last, first, next, add, exit"
and i take 3 inputs from the user...from the JTextField. Those values are put in a file and are supposed to be read (i'm assuming that i use stringtokenizer) but right now i'm using stringbuffer to write to a file. I can't get it to write to the next line though.. it writes next to it..
I'm just hoping that i'm using the correct functions to do this job. Feedback greatly appreciated, i'm really worried about the stringbuffer and having it write the way it should. I didn't do the reading yet.
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
public class BookMaintenance extends JFrame
     private JTextField author;
     private JTextField title;
     private JTextField publisher;
     private JButton add;
     private JButton exit;
     private JButton first;
     private JButton previous;
     private JButton next;
     private JButton last;
     private Container container;
          public BookMaintenance()
               author = new JTextField(10);
               title = new JTextField(10);
               publisher = new JTextField(10);
               add = new JButton("Add");
               exit = new JButton("Exit");
               first = new JButton("First");
               previous = new JButton("Prev");
               next = new JButton("Next");
               last = new JButton("Last");
               last.setSize(30,10);
               JPanel jPanel1 = new JPanel();
               jPanel1.add(new JLabel("Title: "));
               jPanel1.add(title);
               JPanel jPanel2 = new JPanel();
               jPanel2.add(new JLabel("Author: "));
               jPanel2.add(author);
               JPanel jPanel3 = new JPanel();
               jPanel3.add(new JLabel("Publisher: "));
               jPanel3.add(publisher);
               JPanel jPanel4 = new JPanel();
               jPanel4.add(first);
               jPanel4.add(next);
               jPanel4.add(previous);
               jPanel4.add(last);
               JPanel jPanel5 = new JPanel();
               jPanel5.add(add);
               jPanel5.add(exit);
               container = this.getContentPane();
               GridLayout gLayout = new GridLayout(5,1);
               container.setLayout(gLayout);
               container.add(jPanel1);
               container.add(jPanel2);
               container.add(jPanel3);
               container.add(jPanel4);
               container.add(jPanel5);     
               ActionListener actionListener = new ButtonListener();
               first.addActionListener(actionListener);
               next.addActionListener(actionListener);
               previous.addActionListener(actionListener);
               last.addActionListener(actionListener);
               add.addActionListener(actionListener);
               exit.addActionListener(actionListener);
class ButtonListener implements ActionListener
         public void actionPerformed(ActionEvent event)
             if(event.getSource() == add)
                         StringBuffer stringBuffer = new StringBuffer();
                         stringBuffer.append(title.getText());
                         stringBuffer.append(" ");
                         stringBuffer.append(author.getText());
                         stringBuffer.append(" ");
                         stringBuffer.append(publisher.getText());
                         stringBuffer.append(" ' ");
                         RandomAccessFile randomAccessFile = null;
                                try
                                randomAccessFile = new RandomAccessFile("file.txt","rw");
                                        System.out.println(stringBuffer.toString());
                                randomAccessFile.seek(randomAccessFile.length()); 
                                randomAccessFile.writeBytes(stringBuffer.toString() );
                                randomAccessFile.close();
                                        catch(IOException ioe){}
          public static void main(String args[])
        BookMaintenance frame = new BookMaintenance();
        frame.setTitle("Book Maintenance");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 250);
        frame.setVisible(true);
      //  frame.setResizable(false);
}

I have, I've tried many different ways.. but it's hard because with your example, you added it by itself.. and i don't know how to change it to take the input from the user instead of what you gave it.
Lookin at your code.. how would i replace this with input from the user? like add the title, author, publisher in there?
          items = new ArrayList<InventoryItem>();
          items.add(new InventoryItem("Java Programming", "A book about java programming."));
          items.add(new InventoryItem("Monkey Soup", "A delicious Dinner Meal."));
          items.add(new InventoryItem("Red", "My Favorite Color"));
          items.add(new InventoryItem("Light Bulb", "An incandescent miracle."));
          items.add(new InventoryItem("Caleb Payne", "Your god."));
          items.add(new InventoryItem("You", "Caleb's bitch."));Message was edited by:
DenisK

Similar Messages

  • Hey guys, im in need of seriously help. i let a friend jailbreak my iphone and now its jus stuck at the apple screen. i tried rebooting it and everything but nothin is working. does anyone have any good advice?

    hey guys, im in need of seriously help. i let a friend jailbreak my iphone and now its jus stuck at the apple screen. i tried rebooting it and everything but nothin is working. does anyone have any good advice?

    put the phone in DFU mode (do a search for how to do this) and restore to the latest firmware. you may have to download the firmware from apple and when selecting restore or update in itunes press the shift key and select the firmware.
    Hope this helps

  • My ipod is majorly screwed up and i need some serious help

    k well lets see
    error states 'can't mount ipod'
    so i tried checking all the wires, restoring the ipod (which didnt work because it couldnt find it) and i scanned all my files for viruses.
    my ipod also makes funny clicking noises when i dont even touch it...
    im just a kid guys.. i need some serious ipod whizz to help me out.. im desperate! ive tried everything

    Hi,
    Firstly please try to deal with "can't mount iPod" issue
    http://docs.info.apple.com/article.html?artnum=93499

  • My Macbook Pro is Infected, Seriously! Please Help!

    I paid 4000$ for my macbook and it was working fine for a year. Now my internet is incredibly slow and sluggish. To load a single web page takes literally 5 minutes wirelessly but still sluggish when plugged up with the ethernet cable. There are popups that are displayed in my browsers firefox and Safari that say "This is not a Joke you are a winner" and prompts me about a Dell notebook I had won. It then redirects me to some adserving site and mentions FreeZinger in the fineprint. Something is going on because I have downloaded and ran multiple virus and DNS changer scans, iAntivirus, securemac, and etc. At first I thought this was a minor problem but its still there. I ran sudo through the terminal and nothing came up. My internet was blazing fast but now is slow no matter where I use it, whether at school, home or work. Please help ASAP because I think my computer needs some serious debugging. Dont tell me I am one of the first to get a virus on a mac. If I need to purchase some insurance and send my mac in please let me know. Any help at all with this issue is greatly appreciated.

    "I paid _*4000$*_ for my macbook"
    Then you were ripped off. The latest top model cost $2,799.00
    "There are popups that are displayed in my browsers firefox and Safari that say "This is not a Joke you are a winner" and prompts me about a Dell notebook I had won."
    Go into your browsers preferences & select the +"Block Pop-Up Windows"+ (or something similar) setting.
    "I have downloaded and ran multiple virus and DNS changer scans, iAntivirus, securemac, and etc."
    Uninstall them all. Not needed for Macs. There are no known viruses for OS X.
    If you want to feel safe from +trojans+ download ClamX which is a free download from their website, Versiontracker & MacUpdate.
    "Dont tell me I am one of the first to get a virus on a mac."
    Try running repair permissions from your HD and afterwards run +repair disk+ and repair permissions from your software install DVD.
    How much HD space do you have left?

  • FCE Beginner having SERIOUS problems. HELP

    I am a FCE begginner and I am having a serious problem and is in need of serious help.
    I am trying to capture video clips into FCE from my Panasonic video camera which is only a Standard Definition video camera using a mini DV tape.
    When I connect to the FW400, it looks okay when I opened up FCE. So, I clicked FILE > CAPTURE.
    I can see my video is being played in the capture window. I then click the Mark-In button. About 15 seconds later, I clicked the Mark-Out button. Then I clicked the Capture Clip button.
    About 10 seconds after clicking the Capture Clip button, a message appear saying that "Dropped frames were detected during the last capture". I clicked OK and an icon appeared on the browser window.
    My problem is this:
    1) What can I do to prevent the dropped frames ?
    2) Why is the icon appear as a red colour background with a red diagonal line ?
    3) Why is it when I drag this icon into the timeline & try to play the captured video, I can only see the word UNRENDERED in blue colour appearing on the canvas ?
    4) I also try to view what I have captured by putting the icon into the viewer window. And what I saw was the word MEDIA OFFLINE. Why can't I viewed what I have captured ?
    Other questions:
    5) After finish capturing, what is the best way to end the capturing ? When to pull of the FW400 cable ? How & when to close the capturing window ?
    6) When the video was playing in the capture window, how do I fast-forward and see the video moving faster at the same time ? (I only know there is a fast-forward button but when I clicked it, the STOP button is automatically activated and I cannot see the video moving)
    Thank you very much. Any help is appreciated.

    Tom Wolsky wrote:
    2. That's because the clip isn't really captured. It's offline.
    3 - 4. Because the clip hasn't been captured.
    5. When you finish capturing close the capture window. If you want you can pull the camera out or leave it connected.
    6. Use the J-K-L keys. J backward, K pause, L forward. Press L a bunch of times and you go fast forward. Remember cameras are not very responsive devices. They're not like decks designed for shuttling tape.
    1. What's the cameras exactly? What's the drive? How's everything connected? What settings are on the media? What settings are you using in FCE?
    Thanks Tom for your answer but I apologise I don't quite understand some of the thing because I am really green in FCE. I use iMovie 09 previously.
    2-3-4 What does offline means ? I mean why is the clip hasn't been captured ? I tried to follow capture clip as indicated in your book pg 59 to 66. But I think what I obtained were something like Fig 4.13 & 4.14 of page 67 in your book.
    Maybe I relate what I did. I am able to see my video playing on the capture video without any problem. So, when I reach a certain part of the video I click the Mark-In button and the Time indicator on the Left hand side change from NOT SET to a certain number. After about 10 to 15 seconds I clicked the Mark Out button and the Time indicator on the Right hand side change from NOT SET to a certain number.
    Then I click the video to stop. Then I clicked the Capture Clip button. After that a black screen appear with a small apple logo at the centre with the bottom saying "Cueing for Source Material" just like fig 4.11 in page 66 of your book. Then I have the same black screen but this time it says "NOW CAPTURING" just like Fig 4.12 in page 66 of your book.
    After that, a message appear saying "Dropped frames were detected during the last capture". I just clicked OK and an icon appeared on the browser window. So, how come the clip hasn't been captured ? The fact that ican warn me of some dropped frames means that something must have been captured, right ? Or is it that ALL frames have been dropped ?
    So, where did I go wrong ?
    5) Ok thanks, I got that
    6) Ok thanks, the J-K-L keys on the keyboard really works !! Yay !!
    1) The model of my video camera is Panasonic NV-GS230. It is only a Standard Definition video camera using mini DV tape.
    I am using a Lacie FW800 external Hardrive to store the media files.
    I connect the Panasonic video camera to the iMac FW400 slot. So far, I have no problem capturing with this video camera in iMovie 09 and iMovie HD 06 using the same slot.
    How do I check the settings on the media ? If you are referring to EASY SETUP, my settings are:
    FORMAT: (all format)
    RATE: (all rates)
    USE: DV NTSC
    Except for System Settings where I set the scratch disk to my external Lacie and changing the Level of Undo in User preference to 32 (just like you suggested in page 43 of your book), the rest my settings on the FCE are all default settings because I did not change anything except the 2 mentioned. Is there any setting in particular that you want to check ?
    Thanks & sorry for being a real slow beginner. Really appreciate your help.
    Thanks

  • How come I can't put music on my ipod? I already have a fair amount of music on my ipod but I have enough space for more. I am using a new computer with itunes and it is telling me if I wasnt to put the new music on my ipd i need to erase my ipod HELP!

    How come I can't put music on my ipod? I already have a fair amount of music on my ipod but I have enough space for more. I am using a new computer with itunes and it is telling me if I wasnt to put the new music on my ipd i need to erase my ipod HELP!

    Because you can only synce with one iTunes library and you are switching libries by using the new computer. To nake this yyour syncing computer:
    - Move all the media(apps, music, synced video and photos etc) to the new computer.
    - Connect the iPofd yo the computer and bake a backup fo the iPod by right clicking on the iPod under Devices in iTunes and select Back Up
    - Restore the iPod from that backup.
    Note that the backup that iTunes makes doe not include media.
    To move mdia to the new computer see:
    iTunes: How to move your music to a new computer
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer

  • I just bought a new iPhone and accidentally backed it up with my old iPhone backup, I do not want this. I lost everything on my new phone and I need it back. PLEASE HELP! This includes pictures and texts, etc.

    I just bought a new iPhone and accidentally backed it up with my old iPhone backup, I do not want this. I lost everything on my new phone and I need it back. PLEASE HELP! This includes pictures and texts, etc.

    So just to be clear, when you say "just bought" how long ago was that? Is it on this new iPhone that you had pictures, texts, etc that you want? Were you backing up to iCloud or onto iTunes?
    This may not help for everything but if you go to iCloud.com and log in, are you able to find your pictures there?

  • Hi can anyone help me. I have a apple macbook laptop OSX 10.5.8 . When i push print, it shows my printer but says cannot communicate with printer. (epson stylus nx125). Do I need new drivers? Please help .  regards Cindy

    Hi can anyone help me. I have a apple macbook laptop OSX 10.5.8 . When i push print, it shows my printer but says cannot communicate with printer. (epson stylus nx125). Do I need new drivers? Please help .  regards Cindy

    Welcome to Apple Support Communities. We're users here and do not speak for "Apple Inc."
    Some basic printer troubleshooting steps before worrying about a printer driver:
    1. Have you tried turning the printer off and back on?
    2A. Is the printer attached with a cable?
         If yes, have you tried unplugging and re-plugging both ends of the printer cable?
         If that does not help, can you test the printer with another cable?
    2B. If your printer is not connected to the computer with a cable, have you tried restarting your printer (assuming wireless connection)?
         Have you tried restarting your wireless router?
    3. Have you tried restarting your MacBook? (Be sure to save your work first.)
    4. Does the printer have ink? (Doesn't usually generate a 'communications error' though)
    5. Have you updated OS X or the program you're trying to print from recently?

  • HT4208 I just need a little bit of help. I visited the american ap store looking for the new scrabble game which is not available in the australian ap store. Can't get it anyway as I don't have an account there. I am trying to get back to the australian a

    I just need a little bit of help. I visited the american ap store, using my i phone, to check out something. I dont have an account with them so I couldn't get what I wanted anyway.Now, I need to get back to the australian store and I don't know how to do that. Please help!

    Go to app store- scroll down to bottom- click on apple id- change country

  • I made a big mistake in purchasing ringtone Edited by Host ASAP; I'm afraid that my card will be charged a lot; please call me...I need a live person to help me on this matter

    I purchased 2 ringtones in "i tune store", but i think i made a big mistake; please help me because Im afraid that i will be charged a lot; <Edited by Host> ; i need a live person to help me.
    Catherine

    These forums are not moderated by Apple, we are all Users like you.
    Posting your personal phone number here is a terrible idea.  I'll report your post to have a moderator edit out the sensetive info.
    As to your actual concern, you can use iTunes Support, which also will refer you to THIS article (http://support.apple.com/kb/HT1933 about reporting issues with iTunes purchase

  • I have QuickTime Player 7.6.8, I cannot update or remove it b/c I am missing QuickTime.msi file. It is gone and I need it back. Please help.

    I have QuickTime Player 7.6.8, I cannot update or remove it b/c I am missing QuickTime.msi file. It is gone and I need it back. Please help.

    Unfortunately, this sort of trouble has gotten more complicated to deal with ever since Microsoft pulled the Windows Installer CleanUp utility from their Download Center on June 25. First we have to find a copy of the utility.
    Let's try Googling. (Best not to use Bing, I think.) Look for a working download site for at least version 3.0 of the Windows Installer CleanUp utility. After downloading the utility installer file (msicuu2.exe), scan the file for malware, just in case. (I use the free version of Malwarebytes AntiMalware to do single-file scans for that.)
    If the file is clean, to install the utility, doubleclick the msicuu2.exe file you've downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any QuickTime entries and click "Remove".
    Quit out of CleanUp, restart the PC and try installing iTunes again. Does the install go through properly now?
    (If you do find a clean download site for the correct version of CleanUp, please don't tell me where it is. Without wishing to sound paranoid (although I grant it does sound paranoid), there is a non-zero chance that posting links to download locations for the utility here at Discussions leads to that download location being shut down.)

  • BdAqua, anyone.. I need some SERIOUS advise here..

    For many of you I have been on these forums for quite sometime and now I am in need of SERIOUS advice. With the acquisition of a Power Mac G5 Quad taking over most of my everyday activities which I do on my mac pro, I am in desperate need of trying to figure out how I can get the best out of my 2009 mac pro of which I worked so hard in making it a 6-core 2010 machine.. Now I am thinking I might have gone overboard, way overboard as I am not making use of the machine and its fullest potential. I don't have really a lot of income coming in right now as I am unemployed, though I am getting a pension and unemployment, but not enough to buy serious applications for taking advantage of the power in my mac pro.
    Can someone advise on how I can get the best out of my 6-core mac pro without having to spend 1000's of dollars on stuff I may or may never ever need? Other than video editing, is there any other way I can get the best out of using my machine for what its intended for? Here is what I currently use my mac pro for, thus far:
    1. Everyday stuff, browsing internet, forums, emailing.
    2. sometimes I will burn two dvds/cd's simultaneously, sometimes not.
    3. Retro gaming though I do have some older modern games I play from time to time.
    4. I had bootcamp installed, but no more as I can do most of the work I need on the OS X platform.
    5. When I ever get dvds, I rip them using handbrake just to take advantage of all my cores, even though mactheripper is much faster and only uses some of the cores.
    As of right now most of the above I do on my newly acquired Power Mac G5 Quad and my mac pro is on the floor, disconnected and not being used. The problem is that I got the mac pro because of its expandability and I realize my BIGGEST MISTAKE here was that it is in no way a consumer type machine, but for many years I have used desktop macs for my purposes and expansion.
    This is my only intel mac, as my PB G4 is being used for my mobile computing and does everything I throw at it, Power Mac G5 does also what I through at it. The G4 Pismo is only used for OS 9 nostalgia to if I ever have a yearn to retro back to the beginning days of OS 9
    Question: With my limited amount of funds, what can I do to get the best out of my Mac Pro?? I don't want to sell it for something cheaper or less, as I really do love the expansion capability of the mac pro and its case for prolonging the system. I don't plan on getting a future mac pro as for what I use it for it certainly would be a waste.
    I know I have been rude to some of you and I know its been a rocky road between all of you on this forum and me, but I am now in a desperate, precarious position.. What really can I use my mac pro for other than using it like my PM G5 Quad? I am starting to also think the Quad is overkill, but nevertheless, I have a love for both Intel and PowerPC. And yes, I plan on getting Lion as I do want my mac pro to keep up with at least software and updates to the OS.
    Thank you!
    Romko

    LOL, I think the G5s are already obsolete & a Legacy Mac as far as Apple is concerned, yet MHz per MHz they can still compete favorably with the right SW.
    >Ok, can the G5 Quad still do good with elementary audio and video software?
    Yes.
    >What do you think? The mac pro makes a good server?
    Oh yes.
    >I do plan on getting Lion when it comes out for my mac pro however.
    I wish I could comment on Lion, but NDA, NDA, NDA.
    >Also, is it true I won't be able to charge an ipod touch with the G5's USB ports?
    No iPods here, but Macs have traditionally been weak in USB amperage, I'd think if all else fails an AC powered USB hub would vertainly cure it.
    >Define obsolete?
    No longer supported by Apple... so what's new?
    Right now Leo/10.5.x is still fairly well supported, but when a new OS hits I expect that to stop.
    BTW, we're not llowed to speculate here, so call that a blind guess!

  • HT4097 My ipad and mini pad won't update though it says several apps are in need of update. Please help!

    My ipad and mini pad won't update though it says several apps are in need of updates. Please help!

    Try updating from here:
    App Store>Purchased
    Note: You'll have to look out for apps that need update.

  • HT1386 I have an nano - no clue how to sync it after everything downloaded. HEEEEEELP! I need a smart person to help me. :)

    I have an nano - no clue how to sync it after everything downloaded. HEEEEEELP! I need a smart person to help me.

    You might have better luck in the iPod Nano forum at https://discussions.apple.com/community/ipod/ipod_nano?view=discussions

  • HELP needed !!! pleace help !!

    I have a problem. this is the site (
    http://home.planet.nl/~onbe1102/prikbord.html
    its a flash site and when i click to the name buttons i would
    like to open a *.XLS file or a site.
    the action fore the buttons ar now:
    btnWilliam_mc.onRollOver = function() {
    btnWilliam_mc.gotoAndPlay("_over");
    btnWilliam_mc.onRollOut = function() {
    btnWilliam_mc.gotoAndPlay("_out");
    btnArnold_mc.onRollOver = function() {
    btnArnold_mc.gotoAndPlay("_over");
    btnArnold_mc.onRollOut = function() {
    btnArnold_mc.gotoAndPlay("_out");
    btnAbal_mc.onRollOver = function() {
    btnAbal_mc.gotoAndPlay("_over");
    btnAbal_mc.onRollOut = function() {
    btnAbal_mc.gotoAndPlay("_out");
    pleace help !!! what am i doing wrong????
    HELP needed !!! pleace help !!

    You need a command that tells the button to open something
    btnAbal_mc.onRollOut = function() {
    getURL("name.xls or what ever", "_blank");
    The rollover and rollout are animations and you needed to
    tell the buttons to do something. Hope this helped

Maybe you are looking for

  • All boxes are unchecked...how do I check all boxes without doing it 1 by 1?

    I left my ipod to sync and when I came back my ipod had nothing on it...all was erased and in itunes all boxes beside each song in music folder were unchecked. How do I check all of the boxes again so that I can just uncheck the few I wish to have un

  • Moving the database to a new partition

    Hi: I am trying to move the db to a new partition; from C to D. Can I use Export/Import for this purpose? Export and then install and Create db on the new parition and then Import? Please help?

  • Can I upgrade from Mac OS X 10.0 directly to 10.4 on my iMac G3?

    can i go from 10.0 directly to 10.4 on my G3, and will the install affect the 9.2 that coexists currently w/10.0? i have a hp inkjet working under 9.2 that i don't know will work w/10.4 and i would like to continue to have it available(i do have the

  • Client side: is it safe to add a line to NFS StartupItem for a mount?

    (posted this on tiger client board, but realized that this is actually a better forum for this) I need to mount an nfs share at boot on my clients. I dont want to use fstab, because I need a specific mount location (dont want it to add the /private/N

  • Programming Excel from Java

    How can I copy an EXCEL file from a NT machine to a Unix machine and then present it on client's workstation, when the application server is in Unix. Please think of a situation wherein the EXCEL file got created on NT Server, the application server