New try out-can anyone explain so that I learn this?

Hi all!
I posted last night a tryout for a form that could be used in dogcompetitions. I am a total noob here and have tried to learn java from "head first java "so I would appreciate if someone could explain how I make this little application actually save and put out my filled in data.
* @(#)formular.java
* formular application
* @author
* @version 1.00 2008/9/21
import java.io.*;
import java.awt.*;
import java.awt.event.*;
    class formular extends Frame implements ActionListener {
         TextField t1,t2,t3,t4,t5,t6,t7;
         Label l1,l2,l3,l5,l6;
         Button anml,ngra,nsta;
         formular()
             super("Hundutstllning");
             setLayout(null);
             setBounds(150,50,500,500);
        l1=new Label("Ange ditt namn ");
        t1=new TextField(" ");
        l2=new Label("Ange Ange djurets namn ");
        t2=new TextField(" ");
        l3=new Label("Ange hundens lder ");
        t3=new TextField(" ");
        t4=new TextField(" ");
        l5=new Label("Ange klubb ");
        t5=new TextField(" ");
             t1.setBounds(160,80,101,20);
        l1.setBounds(10,80,101,20);
        t2.setBounds(160,120,180,20);
        l2.setBounds(10,120,121,20);
        t3.setBounds(160,160,210,20);
        t4.setBounds(160,200,210,20);
        l3.setBounds(10,160,131,20);
        t5.setBounds(160,240,100,20);
        l5.setBounds(10,240,141,20);
             add(l1);add(t1);
        add(l2);add(t2);
        add(l3);add(t3);add(t4);
        add(l5);add(t5);
        anml=new Button("Anml");
        anml.setBounds(150,300,50,50);
        ngra=new Button("ngra");
       ngra.setBounds(250,300,70,50);
        nsta=new Button("Nsta");
        nsta.setBounds(350,300,90,50);
             add(anml);
             add(ngra);
             add(nsta);
             anml.addActionListener(this);
             ngra.addActionListener(this);
             nsta.addActionListener(this);
            addWindowListener(new WindowAdapter(){
                     public void windowClosing(WindowEvent we){
                                              System.exit(1);}});
                     setVisible(true);
                public void actionPerformed(ActionEvent ae) {
                              if(ae.getSource()==anml) {
                              File f=new File("c:/text.txt");
                             try{
                                      FileOutputStream fos=new FileOutputStream("c:/anmalningar.txt",true);
                                      String s1=t1.getText();
                                      String s2=t2.getText();
                                      String s3=t3.getText();
                                      String s5=t5.getText();
                                      byte b1[]=s1.getBytes();
                                      byte b2[]=s2.getBytes();
                                      byte b3[]=s3.getBytes();
                                      byte b5[]=s5.getBytes();
                                      fos.write(b1);
                                      fos.write(b2);
                                      fos.write(b3);
                                      fos.write(b5);
                                      fos.flush();
                                      fos.close();
                                      catch(Exception e){ }
                                if(ae.getSource()==ngra) {
                                System.exit(1);}
                                    if(ae.getSource()==nsta) {
                                    setVisible(false);
                                                        new formular();
                                        public static void main ( String args[] ) {
                                                  new formular();
                                    }What I want is to be able to save this input data in a list and then get it all again (If say 3 people puts their dog in the application) I want the program to give me back all 3 of the dog applications.

The jump however in response to the above to replies, between AWT and Swing is not huge. many similiar names given to the thier classes. You should go have a look at swing, it will change your life. About the bad code some pointers are...
1) Neat nesting applies to where closing and opening braces of blocks are placed.
2) Dont nest to deep. To reasons apply here.... you need to make yr classes or code block do less. IOW building a whole house should not go in 1 class but should rather have many phases like layBricks() buildRoof() etc and the other reason being the ease of reading which is what you will be critisized most for here.

Similar Messages

  • HT1498 When renting a movie for Apple TV the movie stopped several times interrupting play. Can anyone explain why that might happen?

    WE rented our first movie using Apple TV and at the beginning of the movie it stopped several times and we had to manually restart it. Any suggestions as to how to prevent this?

    What is your actual connection speed (speedtest.net)?
    Are you on wifi? If so have you checked for interference using istumbler or netstumbler or tried Ethernet?
    Are you using your ISPs DNS?

  • Can anyone explain what is happening in this example?

    Take a look at the following bit of CFML:
    <!---\\ This is a coldfusion comment \\--->
    <cfif false>
              <cfsavecontent variable="Test">
                        <?xml version="1.0" encoding="utf-16"?>
              </cfsavecontent>
    </cfif>
    <!---\\ Some other coldfusion code \\--->
    <cfset Foo = 'Hello '>
    <cfset Bar = 'World'>
    <cfset FooBar = Foo & Bar>
    Seems like some simple test code right? Shouldn't generate any output at all right? Now take that sample and go run it. Are you staring at a jumble of oddly encoded characters that basically contain all of the unprocessed CFML code on the page? Because that's exactly what I'm looking at.
    It's the craziest thing! The root issue is the "utf-16" attribute of the XML declaration. If you remove that or change it to something like "utf-8", everything is fine. The points that really muddle my brain are:
    The XML declaration is inside a "cfsavecontent" tag so it should just be a string
    The "cfsavecontent" should not even be evaluated because it's inside of a "cfif" that's hard-coded to false
    My coworker came across this while trying to save some XML as a string so he could write it to a file later. It really seems like a crazy bug to me but I'd like to hear what others think is going on here. For your info, we're running CF9 standard on a Win2k8 R2 system.

    The only thing I can think is that the file itself is saved with UTF-16 encoding, and the CF compiler is baulking at that. That said, I emulated this on my PC and my CF install (same as Duncan's, we work in the same office) dealt with it just fine.
    If the file is saved in any sort of non-ANSI encoding, you will need a <cfprocessingdirective> at the top of the file to tell the CF compiler how to read the file.
    Adam

  • Hello can anyone explain me how to solve this scenario.

    Hello Experts,
    Today i have attended an interview .. the interviewer has given me this scenario and gave me a system and asked me to solve this scenario practically..
    So this is the scenario.. How to solve can any one send me some idea and if possible probable solution..
    <b>scenario.</b>
    IBM sells Notebooks and Machines through dealers.they provide direct selling to corporates.
    .they give 10% discount to orders of 10 pcs and more.
    <b>scope</b>
    <b>.masters</b>
    maintaining dealers
    maintaining product list and price
    maintainig corporate details.
    <b>transactions</b>
    no of orders placed and delivery date.
    <b>reports</b>
    . dealer wise order report
    . company stock report
    .sales report monthly and yeraly wise.
    So what i am asking you is kindly guide me how to approach to solve this scenario.

    this is the exception,I don't know why this exception exist sometimes and isn't exist sometimes
    java.io.UTFDataFormatException
         at java.io.ObjectInputStream$BlockDataInputStream.readUTFSpan(ObjectInputStream.java:2963)
         at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:2888)
         at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2701)
         at java.io.ObjectInputStream.readString(ObjectInputStream.java:1536)
         at java.io.ObjectInputStream.readTypeString(ObjectInputStream.java:1344)
         at java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:540)
         at java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:762)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1503)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
         at REDCSecurity.RSAKeyPair.readFromFile(RSAKeyPair.java:122)
         at REDCTools.USBHandler.getPrivKey(USBHandler.java:99)
         at REDCClient.Disconnected.compare(Disconnected.java:289)
         at REDCClient.Disconnected.authenticate(Disconnected.java:185)
         at REDCClient.Disconnected.connect(Disconnected.java:75)
         at REDCClient.ConnectionAgent.connect(ConnectionAgent.java:28)
         at REDCClient.testConnect.main(testConnect.java:13)

  • I keep getting an error message when downloading a new app which states " Zinio and 5 other apps cannot be purchased at this time" and then it let's me purchase the app that I was looking at? Can anyone explain that?

    I keep getting an error message when downloading a new app which states " Zinio and 5 other apps cannot be purchased at this time" and then it let's me purchase the app that I was looking at? Can anyone explain that?

    apple_master New Delhi, India
    This solved my questionRe: Unable to Purchase 
    Apr 16, 2012 10:22 PM (in response to eight4seven)
    This worked for someone
    I had this problem for about six weeks. I was following this forum but was too unsure of what might happen to try the fixes that were suggested.
    About two weeks ago I decided to delete the downloads.28.sqlitedb file (usingDiskAid(a free program), on a PC running Windows 7). The original downloads.28.sqlitedb was 936 KB. The new one that the system created is 80 Kb., and has stayed at about that size. After about four days I also deleted all the other contents of the Download folder. Ten days later and still no more problems. Downloads are much quicker, nothing greys-out (as was happening frequently before).
    Everything has worked well since with no more error messages.
    I am using an iPod 4G, iOS 5.1 (originally iOS 5.0). I do not have a manifest file, and as far as I know, have not had one. DiskAid can search the whole "hard drive" on the iPod.
    Deleting downloads.28.sqlitedb and the contents of Downloads worked for me.

  • TS1559 I have done all of the steps that Apple have said to do, including completely restarting my phone and registering it as a new one, but still my wifi is greyed out, can anyone help me?

    I have done all of the steps that Apple have said to do, including completely restarting my phone and registering it as a new one, but still my wifi is greyed out, can anyone help me?

    http://support.apple.com/kb/ht5621

  • I try to play an album on ITunes for Windows 7and it plays the first track then randomly goes to a different album and plays the whole of that. Can anyone explain why? Shuffle is turned off....

    I try to play an album on ITunes for Windows 7and it plays the first track then randomly goes to a different album and plays the whole of that. Can anyone explain why? Shuffle is turned off....

    I am working on a friend of mine's 15g ipod(W/dock connector)and I am having the same trouble except it does it to all the songs. I have tried reseting it multiple times, but to no avail.
    I am not sure that this runs on windows XP, it is absolutly archaic (compared to my 5th gen. 30g video).
    Help?
    15g ipod (w/dock connector)   Windows XP  
      Windows XP  

  • When i try to up load the new ios 5 my computer stop at the processing file stage and then says it has timed out can anyone help??

    When i try to up load the ios 5 it stops at the processing file stage and then says that it has timed out can anyone help??

    Disable your antivirus and firewall software.

  • How does this happen: The picture of recent apps you get when double clicking the home button showed in Settings-Wifi that I had been connected to a network I have not been near for two months. Its not a recent "image" of Settings-Wifi. Can anyone explain

    How does this happen: The picture of recent apps you get when double clicking the home button showed in Settings-Wifi that I had been connected to a network I have not been near for two months. Its not a recent "image" of Settings-Wifi. Can anyone explain?

    Greetings,
    I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
    At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
    The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
    I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
    You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
    Good Luck - Cheers,
    M.

  • HT4847 iCloud emails me to say I have exceeded my iCloud storage but Settings tells me I have 18 out of 25gbs available. I can't understand this.... can anyone explain?

    iCloud emails me to say I have exceeded my iCloud storage but Settings tells me I have 18 out of 25gbs available. I can't understand this.... can anyone explain?

    Same problem.  Received a from icloud about 2 hours ago saying that I had exceeded my storage and my mail would be stopped.  Checked all devices and I have 22.5GB available.  It sounds as if there is a problem with icloud?

  • HT1665 I am trying to connect my Samsung Bluetooth device with my new Iphone 4S.  Can anyone explain how this is done?

    I am trying to connect my Samsung Bluetooth device to my new Iphone 4s. Can anyone explain how this is don?

    Which Samsung Bluetooth device?
    Please note that the iPhone will not pair with other phones, tablets, etc for purposes of file transfer.

  • I keep getting a message to update my flash player, then a screen showing flash player pro appears,  I don't have this on my iPad that I'm aware of. I cannot view videos etc (new to ipad) can anyone assist please.

    I keep getting a message to update my flash player, then a screen showing flash player pro appears,  I don't have this on my iPad that I'm aware of. I cannot view videos etc (new to ipad) can anyone assist please.

    Adobe has not made a version of Flash for the iPad.
    Kappy explains why. https://discussions.apple.com/message/19446567#19446567
    5 Flash Player Alternatives http://www.techshout.com/features/2011/01/flash-player-for-ipad-apps/
    Top 4 browsers supports flash player on iPad and iPhone
    http://mashtips.com/flash-player-ios/
     Cheers, Tom

  • My Iphone 4 is changing screens without me touching it. I will be in a msg and it will jump out of that msg and into another one... can anyone please help me with what this could be?

    my Iphone 4 is changing screens without me touching it. I will be in a msg and it will jump out of that msg and into another one... can anyone please help me with what this could be?

    Try the basics from the manual.
    restart.
    reset.
    restore.
    iPhone User Guide (For iOS 4.2 and 4.3 Software)

  • HT3775 I have a .avi file that is not playing. It keeps telling me additional software is needed. I have Mac OS X 10.6.8. Can anyone explain why?

    I have a .avi file that is not playing. It keeps telling me additional software is needed. I have Mac OS X 10.6.8. Can anyone explain why?

    Because there's no codec installed on your system for that specific AVI, and there may be no Mac OS X component for it. Try installing Perian.
    (65484)

  • I am new to mac... and there is a solid black bar on my screen, that announces what page/icon I am on, then scrolls through every screen and announces what it is.  Can anyone tell me how to remove this?? Please? Thank you

    I am new to mac... and there is a solid black bar on my screen, that announces what page/icon I am on, then scrolls through every screen and announces what it is.  Can anyone tell me how to remove this?? Please? Thank you

    You may also find these Links of Interest...
    http://www.apple.com/support/mac101/
    http://www.apple.com/support/switch101/     Switching from PC
    Find Out How (Video)
    http://www.apple.com/findouthow/mac/

Maybe you are looking for

  • Error invoking web service in 10.1.3.0.4

    Hi, Has any one encountered this problem or have an idea what to do about it? When I try to invoke a web service that executes a PL/SQL function that returns a ref cursor,if the select statement joins tables that are in more then one schema, then inv

  • TA38530 Copying music from a hard drive??

    I am trying to copy some music files onto iTunes in my Mac from a friend's iTunes library which is on his hard drive. They are coming over as AAC files and play on my computer on iTunes while his hard drive is connected, but will not play (! error me

  • Creating PDF's with a watermark / template

    Hi Folks, I have a requirement to create PDF Payslips from the system. There is a standard report for converting the spool output of a payslip program to adobe PDF which solves most of the issue however there also needs to be a background image which

  • IPhoto not launching completely

    I haven't been able to access iPhoto for the past two days. I've been on the forums and seen others describe the same problem I'm having (see https://discussions.apple.com/message/15736289#15736289 ) Here's what is happening: 1) Open iPhoto 2) Appear

  • [Oracle JDBC Driver]This driver is locked for use with embedded application

    Hi I installed Sun Java Studio Enterprise 8, and am trying to connect to my Oracle database using the attached tutorial code. The code compiles fine, but I get the following error whenever I run the file: [Oracle JDBC Driver]This driver is locked for