Question about Object-Orientated design for GUI'S

Hi everyone,
I am designing a simple GUI, which basically enables a user to input and retreive data.
So I have a prototype GUI lets call it "myFrame". It extends JFrame, and I place my components onto myFrame, JButtons, JTextfields etc. I have the GUI set up the way I want it, so I move onto implementing the actionListeners.
The problem is that one of the components I have placed on myFrame has its own mouseListener. Its a type of Icon (i created in a seperate class)which extends JComponent, and I thought it would be sensible to give it control of its own mouseListener, so it cuts down on the code within the myFrame class.
But I now realise that I can't alter the other components on myFrame from within the mouseListener in the icon class. I know the icon class doesn't have access to any of myFrames methods or instance fields, so how do I correctly implement this. Surely the answer isn't to bung all the code together into one class?
visually what I have so far looks like this
SERVER <---Requests---> myFrame --------> IconList ---------> Icon
the IconList class looks up a server to update its array of Icons[]. But when one individual Icon is clicked on myFrame, i want its mouseListener to load some of its values onto myFrame's GUI components.
I hope I'm making myself clear, im sorry if this seems like a muddled incoherent question, but any advice would be great. I only need to be shown the correct way to design, and then i carry on coding happily. If this kind of design is way off, please let me know!!
Thanks

You can absolutely do work on the frame from the mouse listener--It just needs an instance. i.e.
public class MyMouseListener implements MouseListener {
  private MyFrame frame;
  public MyMouseListener(MyFrame frame) {
    this.frame = frame;
}Does that make sense?
That said, what you'll see more often is a Model-View-Control approach, wherein the Control (the mouse listener in your case) effects the Model and the Model notifies the View to update its display, rather than the Control updating the view directly. That's the extreme overview version, lots of good hits on google if you're interested beyond that

Similar Messages

  • Question about Object Oriented Design in Oracle

    Hi everyone,
    Right now I'm updating my oracle skills, years ago without programming (last time with Oracle 7.3 :O)
    Well, if I have to design a new system with this features:
    1.- Using Oracle as DB
    2.- Web enable
    3.- OO Design
    My questions:
    1.- What is the best practice to make database design? E-R + Object Types? I mean is better making the design on Oracle directly or in Java-UML environment?
    2.- I was thinking in programming with Forms, but it works well with OO design?
    3.- If I want to program some web services based, Could I do it with PL/SQL and Jdeveloper?
    please if you know about articles and whitepapers about OO design approach with Oracle let me know!
    Thanks.

    I have been involved in some of these projects that have used Java, C#, VB, C++ etc. as front-end languagaes. I have been able to implement these projects successfully using the following approach:
    1. create a relational model of the database - third-normal form (assuming it is an OLTP application)
    2. Write PL/SQL code (packages and procedures mainly)
    3. Interact with the front-end layer by sending and receiving ref curosors and/or PL/SQL tables
    If you want to use Forms (I am assuming Oracle Forms) then there may not be much need for an OO design. Embeeding SQL in the forms will do most of what you want.
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Proper object oriented design for factory class

    I have a factory class (UserFactory) it is capable of creating two types of classes (Customer and Employee) that extend User. User is an abstract class.
    At present any class could create a Customer of an Employee.
    How do I restrict access to the constructors of Customer and Employee only to UserFactory?
    I don't want to make both of these classes interfaces (in which case I could just have UserFactory implement both of them).
    Here is an example of how they are set up at present:
    public abstract class User {
    public class Customer extends User{
    public Customer{
    public class Employee extends User {
    public Employee {
    public class UserFactory ???? {
    private static UserFactory c_userFactory = null;
    private UserFactory (){
    public UserFactory getInstance(){
    //private clone method too
    public Customer createCustomer(){
    public Employee createEmployee(){
    Oh and I don't want to create two separate factory classes for Employee and Customer. In C++ there is a concept of friend classes that would have worked nicely in this case.
    Thanks for any and all suggestions,
    Tim

    So correct me if I'm wrong but your suggestion would be something along the lines of:
    public abstract class User {
    public class Customer extends User{
    protected Customer(){
    public class Employee extends User {
    protected Employee (){
    public class UserFactory ???? {
    private static UserFactory c_userFactory = null;
    private UserFactory (){
    public UserFactory getInstance(){
    //private clone method too
    public Customer createCustomer(){
    public Employee createEmployee(){
    public class AccessForCustomer extends Customer {
    public class AccessForEmployee extends Employee {
    Is the above about what you were talking about? I haven't used inner classes before, so I'm a bit curious. Does this mean no class other than UserFactory or derivatives thereof can access the two classes AccessForCustomer and AccessForEmployee?
    Thanks,
    Tim

  • Exception Handling in Object Oriented Design

    I am developing a huge web based project using Object Oriented design and java,srvlets ,jsp etc ,I am using 3-tier archtecture.I dont understand,how i should handle exceptions in my project.ie.If there is some exception in the base modules how should it be handled.What kind of excpetion Structure should i use,How many exception classes should be made etc,
    Can someone help me in this regard

    A couple things I have found to be good practices for exception handling in an n-tier architecture:
    1. Don't expose all the internal exceptions of a tier to the client of the tier. Create a more useful, descriptive set of exceptions (or use the appropriate predefined exceptions) to throw up to the client.
    For example, on one project, we are doing database access among other things in the "service" tier, which is accessed by the web tier. We catch the SQLExceptions, PersistenceExceptions (a custom exception), and others, and throw a more useful exception that the client will know how to handle such as a NoMeasurementResultsException if the client asks for measurement results when we have none.
    2. Chain your exceptions and/or log the root cause in the tier that re-throws a different exception. There is nothing more aggravating than not knowing why, when you are debugging a problem, you are getting a NoMeasurementResultsException when you know that there ARE results in the database.
    Hope these ideas help in your design.
    Cheers,
    Colin

  • Good book on Object Oriented Design?

    Can you recommend a good book on Object Oriented Design with lots of practical examples? I already have:
    http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=sr_1_1?ie=UTF8&qid=1238324375&sr=8-1
    But currently I need a book with a more basic approach.

    corlettk wrote:
    I like Thinking In Java... Also: google for "yawmark's list"TIJ is useless, especially for teaching OO design. It teaches (or tries to) Java as a procedural language.

  • Question about lead in music for podcasting.

    Question about lead in music for podcasting.
    I listen to many other podcasts and there are those which play lead in music with bit of music inside their podcast. The music are songs we all know and enjoy. I have notice that they only play short small clips of these songs and are not royalty free songs.
    My Question would be is there a limit of time which you can play any song with out paying for it and use it in a podcast legally.
    Thanks Mike

    Legally you cannot use copyright music without written permission or a licence from a recognized authority, no matter how short the clip. Many people do this and get away with it (and for full tracks too) and it's debatable how much notice anyone is likely to take, or whether they would be bothered about a short clip. But the legal position is, it's not legal.

  • Open source my OIOIC, a completely new object-oriented mechanism for t

    OIOIC is a completely new object-oriented mechanism for the C programming language.
    Using OIOIC, you can describe the flower, birds, grass, insects, trees, houses ...
    Using OIOIC, you can describe the elements, atoms, protons, electrons ...
    Using OIOIC, you can describe the earth, the sun, the Milky Way galaxy, collapsar ...
    Using OIOIC, you can describe ...
    1. OIOIC perfectly supplies the gap of object-oriented technology for the C programming language;
    2. OIOIC perfectly solved the multiple inheritance problem in the Software World;
    3. OIOIC perfectly objectivizes multithreading access control of object;
    4. OIOIC unifies the norm of components in the Software World;
    5. OIOIC unifies the structure of code tree in the Software World;
    6. OIOIC unifies the thinking of object-oriented programming in the Software World;
    7. OIOIC unifies all advanced programming languages in the Software World, to make the C programming language as the preferred.
    For further information, please download the "OIOIC-Primer-2nd-Edition-English.tar.gz". (the English version of << OIOIC Primer >> )
    http://code.google.com/p/oioic/downloads/list
    Welcome your advice!

    SamC wrote:It is very, very hard to tell if this is spam. Are you an arch user? Do you think that arch users will be interested in this?
    Firstly, thank you. But it is not spam! The thinking of object-oriented programming is very important for any programmer. Do not you think so.

  • Question about the Filter type for the trace provide "Microsoft-Windows-Kernel-File"

    Hello all,
    I have moved this question from the Windows
    Server General Forum accorfing to the suggestion from Mr. Justin Gu 
    I have a question about the Filter function for the trace provider "Microsoft-Windows-Kernel-File".
    I can find the Filter function with the following operation.
    Mr. Justin Gu wrote:
    > You create a Data Collector Set for the trace provider "Microsoft-Windows-Kernel-File" and finish completely, then you > can right click it and select Properties.
    In the Properties dialog box, click Filter and
    then select ‘Edit…’. You will be> able
    to see the Filter type and Filter data in the Filter dialog box.
    What
    Kind of Filter can
    I use in this Filter dialog box?
    And, how can I set to exclude the some kind of datas?
    Could you give me your suggestion?
    Thank you.

    What
    Kind of Filter can
    I use in this Filter dialog box?
    And, how can I set to exclude the some kind of datas?
    Could you give me your suggestion?
    Thank you.
    I'm looking for the same information.

  • A question about Object Class

    I got a question about Object class in AS3 recently.
    I typed some testing codes as following:
    var cls:Class = Object;
    var cst:* = Object.prototype.constructor;
    trace( cls === cst); // true
    so cls & cst are the same thing ( the Object ).
    var obj:Object = new Object();
    var cst2:* = obj.constructor.constructor;
    var cst3:* = obj.constructor.constructor.c.constructor;
    var cst5:* = Object.prototype.constructoronstructor;
    var cst4:* = Object.prototype.constructor.constructor.constructor;
    var cst6:* = cls.constructor;
    trace(cst2 === cst3 && cst3 === cst4 && cst4 === cst5 && cst5 === cst6); //true
    trace( cst == cst2) // false
    I debugged into these codes and found that cst & cst2 had the same content but not the same object,
    so why cst & cst2 don't point to the same object?
    Also, I can create an object by
    " var obj:Object = new cst();"
    but
    " var obj:Object = new cst2();"
    throws an exception said that cst2 is not a constructor.
    Anyone can help? many thanks!

    I used "describeType" and found that "cst2" is actually "Class" class.
    So,
    trace(cst2 === Class); // true
    That's what I want to know, Thank you.

  • Explain an object-oriented method for a conversion between the E/R diagram

    Somebody can explain me with an example an object-oriented method for a conversion between the E/R diagram and a relational database schema.
    Thanks,

    Hello here are some tips regarding how to convert ERD into Relational objects.
    (1) One to many relationships:
    One to many relationships can be explained by following example.
    Take example of department and Employee. One employee can work in one department only but one department can have more then one employees. In one to many relationship Primary key of One side (here department table) goes to Many side as foreign key (here Employee table).
    (2) Many to Many relationships:
    Many to many relationships can be explained by following example.
    One student can take many subjects and one subject can be taken by more then one student.
    In this case one new table emerges which includes Primary keys of both the tables and establish composite primary key. e.g. here if PK of student is student_id and Pk of course is course_id then new table will emerge named (say) student_course with composite primary key of student_id and course_id (student_id and course_id are also foreign keys)
    (3) One to One:
    Example: A person can have only one tax file number and one tax file number can be allocated to only one person. In this case PK of any table can go to another table as foreign key.
    (4) Super class-sub class relationship:
    Example: person can be a man or woman. Such kinds of relationships are called super class- sub class relationship. There are many ways to convert such relationship into tables
    we can make one table for super class (eg Table Person) and we can put PK of super class in subclass as primary key (eg if person_id is pk of table person then it will go in both sub classes (man, woman) as Pk and it will also be foreign key of the super class (person)
    Note: This is just a way to solve super class relationships there are many other ways which you can choose.
    Thanks
    Ish

  • Question about source system copy for BW

    Dear all,
    I have a quick question about copying a source system for BW.
    We have two clients in the source ERP:
    100 Customizing
    200 Testing
    Our BW is only linked to client 200, so when we now delete client 200 and make a copy from 100 to 200, are we then still able to restore the source system connection so that our extraction will work, or will it fail, as in client 100 I have no BW related (except the cross-client-objects like datasource) information, that can be used for a possible restore of this connection.
    What is the procedure in this case?
    Thanks,
    Andreas

    Unfortunately, you will lose your source connection and need to create a new one in R/3.  You can use the same source system name in BW, but check the source system connection after the copy (SM59).  Also, I would "Restore" the source system (in BW, right-click on Source system in RSA1, and click "Restore") to insure the datasources get replicated from R/3 to BW.
    Depending on how much you want your BW and R/3 systems to be in synch, you will need to rebuild all your data providers (cubes/ODS's) from your R/3 system.  This means deleting all the data and running the initializations from scratch.  At the very least, you will need to rebuild the delta queues.
    Curious, if 100 is just for customizing, is there any data in it?  Are you just creating a new blank client 200?

  • Question about required workshop classes for OCP

    Im working on finishing up my OCP in a few months. Quick question about the workshop class. Is there a test at the end of the week?
    Also how do most people pay for these classes? They are pretty steep and my company doesnt pay for stuff like this for me. Im paying totally out of my own pocket. Also why is the online class the same amount as the instructor lead class? Its not like im in a room at some building that Oracle has to lease for use or something.

    RedDeuce wrote:
    Im working on finishing up my OCP in a few months.What Certificate exactly are you working towards?
    Also how do most people pay for these classes? They are pretty steep and my company doesnt pay for stuff like this for me. Im paying totally out of my own pocket.Then talk to your employer again or maybe look for other jobs that support your plan better.
    Also why is the online class the same amount as the instructor lead class? Its not like im in a room at some building that Oracle has to lease for use or something.They know that you might save on expenses for travel and hotel etc.

  • Question about objects referencing objects?

    I have 3 objects. I call two methods from one, two from another and one method from the last object. I do this in a couple of places. Should I put this particular process into an object method (sixth object) rather than always having to code these calls?
    It seems doing that would violate an object being responsible for itself. Unless I pass all five object methods as parameters into a sixth object. This sixth object will package all these calls for me. Suggestions?
    Thanks,
    Brett

    When you say put the new method on that class, are
    you referring to wrapping all five object methods
    calls in the new method or taking out the specific
    lines of code and wrapping them in the new method?Yes. I don't understand the difference between these two options. Use the "extract method" refactoring on the common lines.
    I assume you mean wrapping object calls into one
    method. Doesn't that violate object orientation
    principles? These method calls won't be coming in
    as parameters right? If so, they'll just be there in
    the method and I won't have a way to verify them.Huh? I don't know what an "object call" is. The common lines will be in a method. What do you mean by "verify them"?
    Also, if these method calls are additional lines of
    code in the new method, what happens when one of
    those methods changes? That could change behavior in
    the new method. Behavior I don't want.It doesn't matter where the method is called. Changes to the behavior of the method will potentially impact every caller. The new method wouldn't be changed any more than the multiple occurences of the same lines in multiple methods you have now. By extracting them to a common method you can deal with the changes in a single place.

  • Some question about the query designer

    hello, dear all,
    I am a new comer of here, and I am intersting in BI, but I have no basic knowledge about it.
    so I just want someone could give me some advice about it.
    our boss need I do the developer about the query designer,  I just have searched in this forum. but nothing founded for I am a new comer here,
    I heard there are some training document of the query designer, could someone give me the URL, thanks.

    Hi,
    Query desinger is used to develop a Query, Query can be created on following data targets
    -Info Cube
    -DSO
    Virtual data target
    -MultiCube
    -Infoset
    -Multiprovider
    We have 5 section in query designer
    - Infoprovider : where we select the data target , on which report to be created
    -Filter : to restrict value at infoprovider level ( if you want data for year 2008, for example)
    -Free Characterstic : this allow you to drill down
    -Columns : char/keyfigs to be display in columns can be added here
    Row: key/char to be display in Rows can be added here
    gv me ur mailid i will let u have Bex manual,
    I would suggest , if you have any IDES ( training ) system , where you can log in and then go to RRMX,
    and try to create new query and add any data target ( which is already created ) and then drag and drop the char/key fig to the required section ,
    save it and execute it .....
    if you play arround and see the output , that would help u to understand how to work with query designer.
    Hope this helps
    Sukhi
    Edited by: Sukhvidner Singh on Nov 4, 2009 5:36 PM

  • Some question about Toshiab reocvery disk for Satellite P300-133

    Hello guys ,
    I got some questions about unpleasant recovery surprises :
    *1)* I just made recovery DVD using Toshiba Recovery Disk Creator and it initially asked for 2 DVDs - but when the first one was done it didn`t require a second blanc DVD . Is it possible all system files of Windows Vista to be written on 1 DVD ?
    *2)* Could I reinstall Windows Vista using the HDD Recovery option ( by pressing F8 ) without using recovery DVD ?
    *3)* Which HDD partitions`ll be formatted ( just system C: or both C: and E: ) using HDD recovery ?
    *4)* What is recovery DVD - Image of the hard drives or Vista installation files ?
    Its pretty bad idea not to include OS on DVD when I have paid for it.
    Thanks for all the problems to Toshiba :(

    1. I think the recovery disk creator means 2 CDs. I have a Portege M700 with Windows Vista and one DVD too. I recovered it and after this I have a clean Vista installation with all drivers and tools from Toshiba. Nothing is missing.
    2. Yes, you can reinstall Vista using the HDD Recovery option when you press F8 at startup. You dont need the recovery DVD but you should create one when your HDD get some errors or something else. If you need a new Recovery DVD, you have pay for one.
    3. The complete HDD and partitions will be formatted, so backup your data first on a DVD, external HDD, USB stick or something else.
    After the reinstallation you have the factory settings.
    4. The recovery DVD is an image of the HDD about the factory settings. If you make a recovery, there are all drivers and tools already installed. Of course on the disk are the installations files of Vista, but you can only use this DVD on your Satellite P300. The disk can not be used on an other Satellite or on a PC.
    When you have more questions, have a look in the user manual. There are a many in formations about the recovery. Its in chapter 3.

Maybe you are looking for