Help with Listener design please

i have an JFrame with a bunch of components...i guess i want all the interactive parts (buttons, jtextfields) to use the same actionlistener...
but i dont want the jframe class to implement it an actionlistener but to use its own listener obj
the one good thing about a class implementing a listener is that the listener has access to all the classes variables (buttons etc), how do i separate the listener into its own class while having access to the implementing class' variables?
this is the way im doing it now
public class IssuePoolListener implements ActionListener{
    private IssuePoolGUI2 owner;
    private JTextField symbolField;
    private JTextField descField;
    private JTextField searchField;
    public IssuePoolListener(IssuePoolGUI2 owner){
        this.owner = owner;       
        symbolField = owner.getSymbolField();
        descField = owner.getDescriptionField();
        searchField = owner.getSearchField();
    public void actionPerformed(ActionEvent e){
    //have access to owners variables
}its ugly.
if i where just to have
public class myJFrame imlements ActionListener{
//all myJFrame code [maybe lots of lines]
    public void actionListener{
    //maybe lots of lines
       if(command.equals(blah)
          blah();
       else if(command.equals(blah2)
           blah2();
       etc
blah(){...have access to all variables...};
blah2(){....have access to all variables...};this way i dont need all those getters, but the myJFrame class is way bigger...
is there a better way? thanks

If the task is small, most any approach will eventually succeed. But you should get in the habit of
writing cohesive classes. And when it comes to making ActionListeners, I like using Action.
As far as the division between your frame (or GUI class) and the ActionListener, if your Listener
knows about IssuePoolGUI2 , methods getDescriptionField and so on, it is then so closely tied to
your GUI class it might as well be part of it -- say an inner class.

Similar Messages

  • Help with access control please

    So I'm trying to set up my brother's PSP to the wirless network through MAC address timed access. What I want to do is make it so that he can only access it through certain times in the day. I'm having troubles with actually getting it to work. Everytime I set it up, the PSP only show's up as a DHCP client and not a Wireless client. I tried the option panel with the add wireless clients through the first try access. Could I get some help with this issue please? Thanks!

    Just to calm your fears... There is no conspiracy. If someone had an answer or a suggestion they would post it.

  • Need help with security design!

    Hi,
    I haven't worked with security design very much. Currently I'm about to develop an application to my father which should implement some sort of security.
    One of the reasons for this application besides making my father happy is educating myself.
    The application is an online image album.
    The security could be divided in role-based security and instance level security.
    Role-based (NO PROBLEM):
    A user cannot delete another user, an administrator can delete users.
    Instance-level (DON'T KNOW HOW):
    A user can load other users image albums if he/her is allowed/granted to view the album and its images. Note that the user could be granted to view the album, but not all of its images.
    My problem is how I should design the "instance-level" security? Should I keep a ACL (Access Control List) with each instance of album and image?
    This seems to be a common functionality to add view/load/read/write permissions to an instance in runtime to let a certain user to operate on an asset?
    Have searched the Internet but haven't found any nice framework to help me.
    Could anyone with some experience please help me out?!
    Kind regards, Andreas

    Hi,
    I ran into the same problem. Could you resolve it?
    please give me your feedback.

  • Need help with class design

    I want to design and use one or more classes for a particular project I am working on.
    I need some advice hopefully from someone who has experience in this area. Basically,
    for this particular problem I have two database tables. I want the first class to
    represent the first database table and the second class to represent the second
    database table. An object of the first class will be created first, and then if certain
    criteria are met then an object of the second class will be created.
    Question:
    Should I use classical inheritance and let the first class inherit from the second class?
    Or should I use the containment delegation model and embed an object of the second
    class in the first class?
    ----Tables------
    For example, my first table ET_UserData looks something like this:
    ET_UserData
    (PK)UserName
    Password
    FirstName
    LastName
    My second table ET_DetailedUserData looks like this
    ET_DetailedUserData
    (FK)UserName
    WorkAddress
    WorkPhoneNumber
    CityWhereEmployed
    SocialSecurityNumber
    City
    State
    StreetAdress
    PrimaryTelephoneNumber
    AlternatePhoneNumber
    HasRegistered
    RegistrationDate
    RegistrationTime
    CreditCardNumber
    NameOfPrimaryContact
    DateOfBirth
    Weight
    EyeColor
    Height
    Member
    Here is are some pseudo classes for the two classes.
    Class UserData
    string UserName
    string FirstName
    string LastName
    Class DetailedUserData /* For a classical approach, sub class off of class UserData */
    /* UserData ThisUser --> Containment delegation model */
    string (FK)UserName
    string WorkAddress
    string WorkPhoneNumber
    string CityWhereEmployed
    string SocialSecurityNumber
    string City
    string State
    string StreetAdress
    Int PrimaryTelephoneNumber
    Int AlternatePhoneNumber
    Bool HasRegistered
    Int RegistrationDate
    Int RegistrationTime
    Int CreditCardNumber
    String NameOfPrimaryContact
    Int DateOfBirth
    Int Weight
    Int EyeColor
    Int Height
    bool Member
    }

    Thank you for your help. If you can continue to help me I would appreciate it.
    I and another developer did the database design. Pretty solid design. Plus we have all of the requirements
    which are very good too.
    Originally I wanted just one table to contain all of the data associated with a user. Instead of ET_UserData and ET_Detailed user data I wanted just one table. But I decided to break this table up into the two tables for the following reason.
    1.) This is a web application where each user logs into a web form. At a minimum, in order to use the website the session associated with each user needs the UserName, Password, First and last name.
    This is the data in the first table.
    If they choose to do more specialized functions on this website, then they will need all of the information (Attributes) that are located in the second table. In general 40% of the time all users will need information located in the second table.
    My reasoning for breaking the table into two seperate tables is that I wanted to minimize the amount of data involved in a result set, created from the sql query. The math tells me that 60% of the time most of the data in the result set will not be used.
    2.) If I create one class to represent all of the data/attributes in both tables, then my reasoning is that their will be alot of overhead in the single class because 60% of the time, a majority of the attributes are not needed and used.
    I would deeply appreciate your help with this. You seem to have great insight and advice. Please help me as I increase the duke dollars Sir.

  • Help with photo albums Please

    Hi, i really need some help with my pictures, I've only got a very basic understanding of how my phone works and have somehow put a load of albums on my phone when i plugged it into the computer-I want to delete some of them off the phone but cannot work out how to do it, when i plug my phone in i can find the photo tab but cannot actually see the pictures and can't see any delete button!!! Please can someone help me, basic explanations would be gratefully recieved xxxx

    The photo sync is one way: computer to phone. To remove photos, synced to your phone, remove the check marks next to the albums/folders under the photos tab in itunes & hit the apply/sync button. They will be removed from your phone. You cannot delete photos that were synced to your phone, directly on your phone. The easiest way to manage photos synced to your phone is to create albums or folders on your computer. Move whatever photos you want on your phone into these albums/folders & then select them under the photos tab in itunes to sync to your phone. You can then remove or add photos to these various albums/folders on your computer & the itunes sync process will update your phone every time you sync.

  • Help with listener.ora

    I'm trying to set up my linux box so someone can telnet in and run a couple of queries in SQL*PLUS. I have th tnsnames.ora file setup correctly - I think. I'm not sure what I'm supposed to do with listener.ora. I know that this file is used by lsnrctl. Can someone give me some help with this? Thanks.

    How did u know that your tnsnames.ora works, when you have not setup listener.ora?
    Anyway, this might help:
    http://homepages.tig.com.au/~jmsalvo/linux/oracle8i-5.html

  • Help with Validation Problem Please

    I don't understand this validation and don't know how to fix it. I have checked my other websites and they seem fine. I don't think I have done anything different The link for the website ishttp://www.greenpatchwebsites.com/pow/index.html
    and the validator is http://validator.w3.org/check?uri=www.greenpatchwebsites.com%2Fpow%2Findex.html&charset=%2 8detect+automatically%29&doctype=Inline&group=0
    Please can you help.
    Thank you very much in advance.

    Thanks for that. I have tried it on a new page: http://www.greenpatchwebsites.com/pow/newtest.html and here is the validator :
    http://validator.w3.org/check?uri=www.greenpatchwebsites.com%2Fpow%2Fnewtest.html&charset= %28detect+automatically%29&doctype=Inline&group=0&No200=1- unfortunately loads of errors
    I also tried the recommended template:
    Use the following markup as a template to create a new XHTML 1.0 document using a proper DOCTYPE. See the list below if you wish to use another document type.
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
         <title>An XHTML 1.0 Strict standard template</title>
         <meta http-equiv="content-type"
              content="text/html;charset=utf-8" />
         <meta http-equiv="Content-Style-Type" content="text/css" />
    </head>
    <body>
         <p>… Your HTML content here …</p>
    </body>
    </html>
    but was getting errors with that. As you can tell, I need serious help with this. Which doc type should I be using
    and why doesn't Dreamweaver just do it for you when you select one?
    Thanks very much again in advance.

  • Help with Option 3 please

    A week ago I was on Option 1 but due to heavy use my speed was reduced to 15.7k/sec !.I was advised to upgrade to Option 3 which I promptly did and that was done on the 29th(last week).
    My speed though is still 15k/sec and I cannot watch any streaming video or BBC News Channels etc
    Would some kind gentleman please look into it for me and advise.......thankyou
    Solved!
    Go to Solution.

    Hi Pete,
    I am sorry for the delay in getting back to you.  I picked your email up this morning and have dropped you a reply.  I am pleased that you managed to sort this out, if you need any further help just let me know.
    Cheers
    Sean
    BTCare Community Manager
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Help with button code please?

    I am a novice and have just completed my first animated movie. I need help with action script.
    The movie is currently looped and I have created and invisible button the size of the frame with the intention that a user can click on the movie image to stop it and on second click continue the movie from where it stopped.
    I have used the AS event handler method to stop the movie. I have tested it and it works. But I cannot figure suitable code to restart the movie.
    Two questions;
    1. am I going about the task the right way? (should I use two buttons, one stop, one start)?
    2. if my approach is feasible, can anyone give me the correct AS to re-start the movie and put me out of my misery please?

    you can use the following after changing "yourbutton" and "yourmovieclip" to use suitable instance names:
    yourbutton.onRelease=function(){
    if(!this.toggle){
    yourmovieclip.stop();
    } else {
    yourmovieclip.play();
    this.toggle=!this.toggle;

  • Help with Required fields-PLEASE

    I have been attempting to get help with a required field and one of the forum helpers said he got it to work for me but I cannot and I have not been able to get any more responses from him to help me further.
    I am attempting to have a radio box when the YES is selected to require another field to be completed.  The script I was provided with is:
    getField("Location").required = (getField("Group1").value == "Yes");
    Location being the field that I require to be filled in if Group 1 is Yes.  The previous forum helper indicated that I had to have this script in both fields in Group 1 and when I do that, nothing different happens. 
    What am I doing wrong? 
    Please, I need to fix this right away and I will be using this java script on many other forms that I have so I need to get this done soon.
    Thank you in advance.

    Wht you want can get somewhat complicated. One way to prevent subsequent fields from being used is to set them to read-only and/or hidden. You could then use the Validate event of the text field to validate the entry and enable the subsequent fields if it is filled-in adequately. In general, you should also reset the fields whenever you hide them, so they don't contain potentially invalid data from previously being filled-in. So you could initially have the fields set to be hidden, and only unhide them if No is selected, or if Yes is selected and the required text field is filled-in.
    I realize this may not be as helpful as you had hoped for, but I can't suggest specific code without knowing more about the form.

  • Help with a routine please

    Hi experts!
    I have a requirement and I need help with an abap routine.
    I'm uploading a table from de ECC where each record contains one key figure per fiscal period (wlt01, wlt02,...wlt16). I need to have in a dso a unique key figure (called zwlt for instance) and the 0fiscper infoobject filled with the corresponding period, that is, for each record of the table, I need 16 records in the DSO with zwlt = wltXX and the fiscper = fiscyear&0&XX.
    Any help please?
    Thanks in advance.

    there are multiple ways to handle this.
    one way is to use APD to unpivot the data.
    or else you can use the following sample code to derive what you want...this code might just hint at the way to proceed.
    TYPES:
      BEGIN OF tys_SC_1,
          wlt01           TYPE P LENGTH 8 DECIMALS 2,
          wlt02           TYPE P LENGTH 8 DECIMALS 2,
          wlt03           TYPE P LENGTH 8 DECIMALS 2,
          wlt04           TYPE P LENGTH 8 DECIMALS 2,
          wlt05           TYPE P LENGTH 8 DECIMALS 2,
          wlt06           TYPE P LENGTH 8 DECIMALS 2,
          wlt07           TYPE P LENGTH 8 DECIMALS 2,
          wlt08           TYPE P LENGTH 8 DECIMALS 2,
          wlt09           TYPE P LENGTH 8 DECIMALS 2,
          wlt10           TYPE P LENGTH 8 DECIMALS 2,
          wlt11           TYPE P LENGTH 8 DECIMALS 2,
          wlt12           TYPE P LENGTH 8 DECIMALS 2,
      END OF tys_SC_1.
    DATA: ls_type TYPE tys_SC_1,
          l_name TYPE string,
          l_count Type n length 2.
    FIELD-SYMBOLS:
                <fs_type> TYPE tys_SC_1,
                <result>  TYPE P .
    ls_type-wlt01 = '1.1'.
    ls_type-wlt02 = '2.2'.
    ls_type-wlt03 = '3.3'.
    ls_type-wlt04 = '4.4'.
    ls_type-wlt05 = '5.5'.
    ls_type-wlt06 = '6.6'.
    ls_type-wlt07 = '7.7'.
    ls_type-wlt08 = '8.8'.
    ls_type-wlt09 = '9.9'.
    ls_type-wlt10 = '10.1'.
    ls_type-wlt11 = '11.11'.
    ls_type-wlt12 = '12.12'.
    CLEAR:  l_count ,  l_name.
    l_count = '01'.
    ASSIGN ls_type TO <fs_type> .
    Write: / .
    DO 12 TIMES.
      clear: l_name.
      Concatenate 'wlt'  l_count into l_name.
      ASSIGN COMPONENT l_name  OF STRUCTURE  <fs_type> TO <result> .
      Write: / , l_name , ' = ' , <result>.
      l_count = l_count + 1 .
    ENDDO.
    hope it helps.
    Regards
    Ashwin

  • Help with UILabel subclass please

    Hello all... I have a UILabel subclass I call CustomLabel. Ive been googling and reading the apple docs this entire week to figure this out. The few examples Ive seen, I dont think Im doing it right.
    Im trying to create a subclass to use throughout my project. Every label will have these properties so I figured why not subclass. So through a lot of trial and error I ended up with this...
    CustomLabel.h
    #import <UIKit/UIKit.h>
    @interface CustomLabel : UILabel {
    @property (nonatomic) CGSize shadowOffset;
    @property (nonatomic) UITextAlignment *textAlignment;
    @property (nonatomic, retain) UIColor *shadowColor;
    @property (nonatomic, retain) UIColor *textColor;
    @property (nonatomic, retain) UIColor *backgroundColor;
    @property (nonatomic, retain) UIFont *font;
    @end
    CustomLabel.m
    #import "CustomLabel.h"
    #import "Constants.h"
    @implementation CustomLabel
    @synthesize textColor;
    @synthesize backgroundColor;
    @synthesize font;
    @synthesize shadowColor;
    @synthesize shadowOffset;
    - (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
    self.textColor = [UIColor whiteColor];
    self.backgroundColor = [UIColor clearColor];
    self.font = SMALL_CHALKDUSTER;
    self.shadowColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.35f];
    self.shadowOffset = CGSizeMake (0, 2);
    self.textAlignment = UITextAlignmentCenter;
    return self;
    - (void)dealloc {
    [super dealloc];
    @end
    I then allocate a label like so...
    ViewController.h
    CustomLabel *myLabel;
    @property (nonatomic, retain) CustomLabel *myLabel;
    ViewController.m
    myLabel = [[CustomLabel alloc] init];
    myLabel.text = @"Blah blah blah";
    I feel like Im way off on this... I must be since it isnt setting any of the properties Im trying to use in the subclass.
    I found an older post on the forums here for setting the textAlignment but for some reason I couldnt apply the same logic to mine.
    So can anyone help me with this subclass please and thank you?

    xnav... thanks a ton for pointing me to this link. Its got me closer to my end goal than I was before. Right now I have...
    CustomLabel.h
    #import <UIKit/UIKit.h>
    @interface CustomLabel : UILabel {
    @end
    CustomLabel.m
    #import "CustomLabel.h"
    #import "Constants.h"
    @implementation CustomLabel
    - (void) drawRect:(CGRect)rect {
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    UIColor *lineColor = [UIColor whiteColor];
    UIColor *shColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.35f];
    //UIColor *bkgColor = [UIColor clearColor];
    CGContextSetFillColorWithColor(ctx, lineColor.CGColor);
    CGContextSetShadowWithColor(ctx, CGSizeMake(0, 2), self.font.pointSize / 2.0, shColor.CGColor);
    //CGRect drawRect = CGRectMake(rect.origin.x, rect.origin.y,rect.size.width, rect.size.height);
    //CGContextSetAlpha(ctx, 0) ;
    //CGContextFillRect(ctx, drawRect);
    //CGContextSetStrokeColorWithColor(ctx, [[UIColor clearColor] CGColor]);
    //CGContextSetFillColorWithColor(ctx, [[UIColor clearColor] CGColor]);
    CGContextSetBlendMode(ctx, kCGBlendModeClear);
    //CGContextAddEllipseInRect(ctx,CGRectMake(size.width-(size.width/2)-(size.width/10), (size.width/10), (size.width/2), (size.height/2)));
    //CGContextClosePath(ctx);
    //CGContextDrawPath(ctx, kCGPathFillStroke);
    //CGContextSetTextDrawingMode(ctx, kCGTextFillStroke);
    //self.backgroundColor = [UIColor clearColor];
    //[self setBackgroundColor:[UIColor clearColor]];
    [self.text drawInRect:self.bounds withFont:TINY_CHALKDUSTER lineBreakMode:self.lineBreakMode alignment:UITextAlignmentCenter];
    - (void)dealloc {
    [super dealloc];
    @end
    As you can see I have a couple of things commented out. LOL I still cant figure out how to make the background color clear. I also dont know if I need the dealloc in this subclass. But the other properties seem to be working like the font and line color.
    Thanks again for the link and getting me in the right direction xnav. If you can lend any more assistance on how to get that darn background color clear I would appreciate it!

  • Help with Wireless thingy Please!!!

    Hi, could someone please help with this? I am quite computer literate except when it comes to anything wireless or networking as it is something I've never used, so heres the problem - I bought ATV, and put a wireless card in the computer - do i need a seperate router to create a network? ATV searches for a network, and finds one, but I am not sure its mine!! ATV not coming up in itunes. Ive tried everything, but its just not happening. If I need a router, fine I'll get one, but if not could I have some instructions please?!!!! Like what on earth do I put in if adding network to atv manually? How do I know what my network name is? Tried with firewalls disabled, and added ports 3689 and 5353 to exceptions. Bearing in mind I need translations for things like DHCP etc! Its a Belkin Wireless G+ Network Card, compatible with ATV. Please help as this is the only thing standing between me and music heaven!!thankyou!

    On a mac you could create an ad hoc network with a mac with wi-fi card only and internet sharing enabled, I've not done it and I don't know whether one has the choice to name the network or whether it will be identified as the mac's network name. I guess you will need advice from a PC guy as to whether this can be done on a PC, but my guess is that it can.

  • Help with mail installatioin please

    could somebody please help with the installation of mail...I have had my mac for 7 months now, and can't use the mail application.
    Somebody help please before I die?
    thanks
    n9mila

    i don't understand...the whole outgoing thing!
    my email address is in hotmail. k! I don't have a .mac account
    explain this
    "incoming Mail Server: The server where your mail waits for you to retrieve it. Also called a POP or IMAP server. Enter the address (name) of the mail server where your mail account resides, and where mail is stored. For example, mail.example.com."
    and this
    "Outgoing Mail Server: The server that sends your mail to its destination. Also known as an SMTP server. For example, smtp.example.com. To see the server in use by each mail account, choose Edit Server List from the Outgoing Mail Server pop-up menu."
    sorry, I'm very slow to comprehending

  • Need Help with Listener on JInternalFrame

    Below is the code as it is currently.
    public class addCustomer extends JInternalFrame implements ActionListener{
    //Variable declarations here
    private JPanel panel = new JPanel();
    private JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,icon1;
    private JTextField CustNum,CFName,CSName,Address1,Address2,City,PostCode,Tel,Cell;
    private JButton Cancel, Add;
    private ImageIcon pic,FrmPic;
    addCustomer() {
    super ("Add New Customer",true,true,true,true);
    setSize(350,370);
    setResizable(false);
    On the Frame I have a textfield that I would like to add a listener to. When text is typed into the textfield it should enable a JButton on the frame. My problem is that as soon as I implement KeyListener or EventListener on the above code I get an error of the class is not defined as abstract. If I define it as abstract my main declaration that looks like this gives me an error :
    public static void main(String args[]){
    new Video().show();
    Can anyone help me with a work around.
    Alexander

    Still have an error in the code. I don't know what I am doing wrong. this is the code so far.
    //This class will create the the Panel for Adding new Customers
    package VideoShop;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
    import javax.swing.event.*;
    public class addCustomer extends JInternalFrame implements ActionListener{
    //Variable declarations here
    private JPanel panel = new JPanel();
    private JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,icon1;
    private JTextField CustNum,CFName,CSName,Address1,Address2,City,PostCode,Tel,Cell;
    private JButton Cancel, Add;
    private ImageIcon pic,FrmPic;
    addCustomer() {
    super ("Add New Customer",true,true,true,true);
    setSize(350,370);
    setResizable(false);
    //Sets the layout for the panel
    panel.setLayout(null);
    //Creates the labels
    label1 = new JLabel("Customer Nr");
    label2 = new JLabel("First Name");
    label3 = new JLabel("Surname");
    label4 = new JLabel("Address");
    label5 = new JLabel("Address");
    label6 = new JLabel("City");
    label7 = new JLabel("Postcode");
    label8 = new JLabel("Tel Nr");
    label9 = new JLabel("Cell Nr");
    //Creates the Textfields
    CustNum = new JTextField();
    CustNum.setEditable(false);
    CFName = new JTextField();
    CSName = new JTextField();
    Address1 = new JTextField();
    Address2 = new JTextField();
    City = new JTextField();
    PostCode = new JTextField();
    Tel = new JTextField();
    Cell = new JTextField();
    //Creates the buttons
    Cancel = new JButton("Cancel");
    Add = new JButton("Add");
    //Sets the alignment of the label controls
    label1.setBounds(20, 20, 90, 20);
    label2.setBounds(20, 50, 90, 20);
    label3.setBounds(20, 80, 90, 20);
    label4.setBounds(20, 110, 90, 20);
    label5.setBounds(20, 140, 90, 20);
    label6.setBounds(20, 170, 90, 20);
    label7.setBounds(20, 200, 90, 20);
    label8.setBounds(20, 230, 90, 20);
    label9.setBounds(20,260,90,20);
    //Sets the alignment of the Textfield controls
    CustNum.setBounds(100,20,90,20);
    CFName.setBounds(100, 50, 90, 20);
    CSName.setBounds(100, 80, 90, 20);
    Address1.setBounds(100, 110, 130, 20);
    Address2.setBounds(100, 140, 130, 20);
    City.setBounds(100, 170, 100, 20);
    PostCode.setBounds(100, 200, 65, 20);
    Tel.setBounds(100,230, 90,20);
    Cell.setBounds(100, 260, 90, 20);
    //Sets the alignment of the Button controls
    Add.setBounds(200, 310, 90, 20);
    Cancel.setBounds(85,310,90,20);
    //Creates an icon on the panel
    pic = new ImageIcon("/VideoShop/NotePad.gif");
    icon1 = new JLabel(pic);
    icon1.setBounds(280,10,50,50);
    //Adds Mnemonics
    Cancel.setMnemonic('c');
    Add.setMnemonic('a');
    //Adds listener to the Cell TextField to help with validation
    Cell.getDocument().addDocumentListener(new DocumentListener(){
    public void changeUpdate(DocumentEvent e){
    public void removeUpdate (DocumentEvent e){    
    adjust(e);
    public void insertUpdate(DocumentEvent e){      //ERROR////////////
    adjust(e);
    //Adds listeners to the buttons on the panel
    Cancel.addActionListener(this);
    Add.addActionListener(this);
    //Adds the controls to the panel
    panel.add(label1);
    panel.add(label2);
    panel.add(label3);
    panel.add(label4);
    panel.add(label5);
    panel.add(label6);
    panel.add(label7);
    panel.add(label8);
    panel.add(label9);
    panel.add(CustNum);
    panel.add(CFName);
    panel.add(CSName);
    panel.add(Address1);
    panel.add(Address2);
    panel.add(City);
    panel.add(PostCode);
    panel.add(Tel);
    panel.add(Cell);
    panel.add(Cancel);
    panel.add(Add);
    panel.add(icon1);
    //Gets the next customer number from the database
    //Variables for the database
    String dbuser = "";
    String dbpasswd = "";
    String DriverPrefix = "jdbc:odbc:";
    String DataSource = "Video";
    //Holds the value from the database
    String val1;
    //SQL String for writing data to database
    String SQLstring = "SELECT CustNum FROM Customers";
    //Loads the driver for the database
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null,"Error Loading driver\n"+e,"Driver Load Error",JOptionPane.WARNING_MESSAGE);
    Statement stmt = null;
    Connection con = null;
    //Create a connection to the database.
    try {
    con = DriverManager.getConnection(DriverPrefix+DataSource,dbuser, dbpasswd);
    stmt = con.createStatement();
    }catch (Exception e) {
    JOptionPane.showMessageDialog(null,"Cannot connect to Database\n"+e,"Connection Error",JOptionPane.WARNING_MESSAGE);
    ResultSet rs = null;
    //Gets data from the database
    try {
    rs = stmt.executeQuery(SQLstring);
    while (rs.next()){
    val1 = rs.getString(1);
    int val2 = Integer.parseInt(val1);
    val2++;
    CustNum.setText(String.valueOf(val2));
    } catch (Exception e){
    JOptionPane.showMessageDialog(null,"Cannot connect to database\n"+e,"Communication Error",JOptionPane.WARNING_MESSAGE);
    try {
    con.close();
    } catch (Exception e){
    JOptionPane.showMessageDialog(null,"Cannot close database\n"+e,"Error",JOptionPane.WARNING_MESSAGE);
    //Adds the panel to the InternalFrame and display it
    getContentPane().add(panel);
    show();
    //Here all action events are processed
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == Cancel){
    dispose();
    if (e.getSource() == Add){
    ToDatabase();
    //Here the document event is processed
    public void adjust(DocumentEvent e){
    Cell.setEnabled(e.getDocument().getLength()>0);
    //Here the data will be sent to the database
    public void ToDatabase() {
    //Variables for the database
    String dbuser = "";
    String dbpasswd = "";
    String DriverPrefix = "jdbc:odbc:";
    String DataSource = "Video";
    //SQL String for writing data to database
    String SQLstring ="INSERT INTO Customers VALUES('"+CustNum.getText()+"', '"+CFName.getText()+"','"+CSName.getText()+"','"+Address1.getText()+"','"+Address2.getText()+"','"+City.getText()+"','"+PostCode.getText()+"','"+Tel.getText()+"','"+Cell.getText()+"')";
    //Loads the driver for the database
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null,"Error Loading driver\n"+e,"Driver Load Error",JOptionPane.WARNING_MESSAGE);
    Statement stmt = null;
    Connection con = null;
    //Create a connection to the database.
    try {
    con = DriverManager.getConnection(DriverPrefix+DataSource,dbuser, dbpasswd);
    stmt = con.createStatement();
    }catch (Exception e) {
    JOptionPane.showMessageDialog(null,"Cannot connect to Database\n"+e,"Connection Error",JOptionPane.WARNING_MESSAGE);
    //Transfer data to database
    try {
    stmt.executeUpdate(SQLstring);
    con.close();
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null,"Cannot update database\n"+e,"Communication Error",JOptionPane.WARNING_MESSAGE);
    dispose();
    The error that I receive is this:
    VideoShop/addCustomer.java [98:1] <anonymous VideoShop.addCustomer$1> is not abstract and does not override abstract method changedUpdate(javax.swing.event.DocumentEvent) in javax.swing.event.DocumentListener
    public void insertUpdate(DocumentEvent e){      //ERROR////////////
    ^
    1 error
    Errors compiling addCustomer.
    Is there a way around this or should I rewrite the whole class.
    Thanks
    Alexander

Maybe you are looking for