Update methode in model-view-controller-pattern doesn't work!

I'm writing a program in Java which contains several classes. It must be possible to produce an array random which contains Human-objects and the Humans all have a date. In the program it must be possible to set the length of the array (the number of humans to be produced) and the age of the humans. In Dutch you can see this where is written: Aantal mensen (amount of humans) and 'Maximum leeftijd' (Maximum age). Here you can find an image of the graphical user interface: http://1.bp.blogspot.com/_-b63cYMGvdM/SUb2Y62xRWI/AAAAAAAAB1A/05RLjfzUMXI/s1600-h/straightselectiondemo.JPG
The problem I get is that use the model-view-controller-pattern. So I have a model which contains several methodes and this is written in a class which inherits form Observable. One methode is observed and this method is called 'produceerRandomArray()' (This means: produce random array). This method contains the following code:
public void produceerMensArray() throws NegativeValueException{
     this.modelmens = Mens.getRandomMensen(this.getAantalMensen(), this.getOuderdom());
for (int i = 0; i < this.modelmens.length; i++) {
          System.out.println(this.modelmens.toString());
this.setChanged();
this.notifyObservers();
Notice the methods setChanged() and notifyObservers. In the MVC-patterns, these methods are used because they keep an eye on what's happening in this class. If this method is called, the Observers will notice it.
So I have a button with the text 'Genereer' as you can see on the image. If you click on the button it should generate at random an array. I wrote a controller with the following code:
package kristofvanhooymissen.sorteren;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**Klasse GenereerListener.
* @author Kristof Van Hooymissen
public class GenereerController implements ActionListener {
     protected StraightSelectionModel model;
     /**Constructor.
     *@param model Een instantie van het model wordt aan de constructor meegegeven.
     public GenereerController(StraightSelectionModel model) {
          this.model = model;
     /**Methode uit de interface ActionListener.
     * Bevat code om de toepassing te sluiten.
     public void actionPerformed(ActionEvent arg0) {
     this.model=new StraightSelectionModel();
     try{
     this.model.produceerMensArray();
     } catch (NegativeValueException e){
          System.out.println("U gaf een negatieve waarde in!");
     this.model.setAantalMensen((Integer)NumberSpinnerPanel.mensen.getValue());
     this.model.setOuderdom((Integer)NumberSpinnerPanel.leeftijd.getValue());
StraighSelectionModel is of course my model class. Nevermind the methods setAantalMensen and setOuderdom. They are used to set the length of the array of human-objects and their age.
Okay. If I click the button my observers will notice it because of the setChanged and notifyObservers-methods. An update-methode in a class which implements Observer.
This method contains the follow code:
public void update(Observable arg0,Object arg1){
          System.out.println("Update-methode");
          Mens[] temp=this.model.getMensArray();
          for (int i = 0; i < temp.length; i++) {
               OnbehandeldeLijst.setTextArea(temp[i].toString()+"\n");
This method should get the method out of the model-class, because the produceerRandomArray()-methode which has been called by clicking on the button will save the produce array in the model-class. The method getMensArray will put it back here in the object named temp which is an array of Mens-objects (Human-objects). Then aftwards the array should be put in the textarea of the unsorted list as you could see left on the screen on the image.
Notice that in the beginning of this method there is a System.out.println-command to print to the screen as a test that the update-method has been called.
The problem is that this update method won't work. My Observable class should notice that something happened with the setChanged() and notifyObservers()-methods, and after this the update class in the classes which implement Observer should me executed. But nothing happenens. My controllers works, the method in the model (produceerRandomArray() -- produce random array) has been executed, but my update-method won't work.
Does anyone has an explanation for this? I have to get this done for my exam an the 5th of january, so everything that could help me would be nice.
Thanks a lot,
Kristo

This was driving me nuts, I put in a larger SSD today going from a 120GB to a 240GB and blew away my Windows Partition to make the process easier to expand OS X, etc.  After installing windows again the only thing in device manager that wouldn't load was the Bluetooh USB Host Controller.  Tried every package in Bootcamp for version 4.0.4033 and 5.0.5033 and no luck.
Finally came across this site:
http://ron.dotsch.org/2011/11/how-to-get-bluetooth-to-work-in-parallels-windows- 7-64-bit-and-os-x-10-7-lion/
1) Basically Right click the Device in Device manager, Go to Properties, Select Details tab, Choose Hardware ids from Property Drop down.   Copy the shortest Value, his was USB\VID_05AC&PID_8218 
2) Find your bootcamp drivers and under bootcamp/drivers/apple/x64 copy AppleBluetoothInstaller64 to a folder on your desktop and unzip it.  I use winrar to Extract to the same folder.
3) Find the files that got extracted/unzipped and open the file with notepad called AppleBT64.inf
4) Look for the following lines:
; for Windows 7 only
[Apple.NTamd64.6.1]
; No action
; OS will load in-box driver.
Get rid of the last two lines the following:
; No action
; OS will load in-box driver.
And add this line, paste your numbers in you got earlier for USB\VID_05ac&PID_8218:
Apple Built-in Bluetooth=AppleBt, USB\VID_05ac&PID_8218
So in the end it should look like the following:
; for Windows 7 only
[Apple.NTamd64.6.1]
Apple Built-in Bluetooth=AppleBt, USB\VID_05ac&PID_8218
5) Save the changes
6) Select Update the driver for the Bluetooth device in device manager and point it to the folder with the extracted/unzipped files and it should install the Bluetooth drivers then.
Updated:
Just found this link as well that does the same thing:
http://kb.parallels.com/en/113274

Similar Messages

  • Real Model View Controller with JTextField

    Hi!
    I am new to Java (so please bear with me). I am building a swing application. I already have added a JTable with a corresponding table model that extends AbstractTableModel. Rather than store the data in the table model, I have modified setValueAt and getValueAt to write and read cell data to another location. So far, everything is fine. When doing setValueAt, I have a fireTableCellUpdated statement that I use to update the edited cell. So far, things are all still fine.
    I would like to do the same thing with a JTextField. I found an example in Core Java Volume 1 for create a class that extends PlainDocument. It uses insertString to update the document in a way that ensures that only numbers are entered. I implemented this. Everything is still fine. I changed insertString to update my remote repository (a field in another class). Everything is still fine. Next, I tried to change (override) both getText methods to read from the repository. This works, but is not reflected on the screen.
    I realize that I need the equivalent of a fireTableCellUpdated statement for the class that extends PlainDocument, but do not know how to do this.
    I have looked a lot over the internet for the model view controller implementation. I know that it can be done using event and event listeners, but this seems to defeat the purpose of the model view controller - it seems like you ought to be able to directly modify the model object to access external data.
    My code is below.
    Thanks/Phil Troy
    * PlainDocument class to make it possible to:
    * - Make sure input in unsigned integer
    * - Automatically save data to appropriate locate
    * This will hopefully eventually work by overriding the insertString and getText methods
    * and creating methods that can be overridden to get and save the numerical value
    class UnsignedIntegerDocument extends PlainDocument
         TutorSchedulerPlusSettings settings;
         JTextField textField;
         public UnsignedIntegerDocument(TutorSchedulerPlusSettings settings)
         {     super();
              this.settings = settings;
         public void setTextField(JTextField textField)
         {     this.textField = textField;
         // Overridden method
         public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
         {     if (str == null) return;
              String oldString = getText(0, getLength());
              String newString = oldString.substring(0, offs) + str +oldString.substring(offs);
              try
              {     setValue(Integer.parseInt(newString));
                   super.insertString(offs, str, a);
                   fireInsertUpdate(new DefaultDocumentEvent(offs, 10, DocumentEvent.EventType.INSERT));
              catch(NumberFormatException e)
         public String getText()
         {     return String.valueOf(getValue());
         public String getText(int offset, int length) throws BadLocationException
         {     String s = String.valueOf(getValue());
              if (length > 0)
                   s = s.substring(offset, length);
              return s;
         public void getText(int offset, int length, Segment txt) throws BadLocationException
         {     //super.getText(offset, length, txt);
              char[] c = new char[10];
              String s = String.valueOf(getValue());
              s.getChars(offset, length, c, 0);
              txt = new Segment(c, 0, length);
         public String getValue()
         {     int i = settings.maxStudents;
              String s = String.valueOf(i);
              return s;          
         void setValue(int i)
         {     settings.maxStudents = i;
    }

    Hi!
    Thanks for your response. Unfortunately, based on your response, I guess that I must not have clearly communicated what I am trying to do.
    I am using both JTables and JTextFields, and would like to use them both in the same way.
    When using JTable, I extend an AbstractTableModel so that it refers to another data source (in a separate class), rather than one inside of the AbstractTableModel. Thus the getValueAt method, getColumnCount method, setValueAt method, . .. all call methods in another class. The details of that other class are irrelevant, but they could be accessing data from a database (via JDBC) or from other machines via some other communication mechanism.
    I would like to do exactly the same thing with a JTextField. I wish for the data to come from a class other than an object of type PlainDocument, or of any class that implements the Document interface. Instead, I would like to use a class that implements the Document interface to call my external class using methods similar to those found in AbstractTableModel.
    You may ask why I would like to to this. I have specific reasons here, but more generally this would be helpful when saving or retrieving parameters set and displayed in a JTextField to a database, or when sharing JTextField to multiple users located on different machines.
    As to whether this is real MVC or not, I think it is but it really doesn't matter.
    I know that I can accomplish what I want for the JTextField using listeners. However, I would like my code for the JTables to be similarly structured to that of the JTextField.
    Thanks/Phil Troy

  • WebCenter Sites and Model–view–controller (MVC) framework

    A customer of our started developing their sites using Webcenter Sites, they want to support additional functionality such as transaction management, exception handling, custom logging and so on. I was wondering if anyone has experience with the Model–view–controller (MVC) framework, they consider it an ideal candidate for these features. Has anyone here used the MVC framework in conjunction with WebCenter Sites to write additional java classes, facade layers and utilize the Spring controller to wire the same ? Are you aware of any other options available for this purpose ?
    regards,
    Pietro

    Hi Pietro -
    Using Sites IN a MVC framework is very difficult, because the entire context of WebCenter Sites is burned into the COM.FutureTense.Servlet.SContentServer servlet.  You can't really work around that with any degree of reliability.  Unfortunately, that means that dropping Sites into a pre-existing third party MVC framework doesn't really work. 
    There are a lot of good reasons for that, not the least of which is the two-tiered pagelet-level caching system that makes Sites so very fast at delivery... not that it's any consolation.
    To deal with this some former colleagues of mine and I built the GST Site Foundation ("GSF") framework, which provides a Spring-like MVC container WITHIN sites, instead of the other way around.  If you're familiar with Spring, you'll see patterns similar with the GSF.  My current team and I have blogged about this extensively:
    What is this whole GST Site Foundation thing? | Function1
    Create a Simple "Contact Us" Form with GSF | Function1
    How to Add Your Own DAO to the GSF Actions | Function1
    The full stream is here:  GSF | Function1
    But ultimately, the special sauce is the following: in Sites, create an XML element that contains nothing but a <FTCS> tag, a <CALLJAVA> tag, and a closing </FTCS> tag.  Your CALLJAVA will then call a class that implements the Seed or Seed2 interface, and from in there you have access to the (properly managed) ICS object where you can do all of your magic.  You can then build a lightweight controller here to handle any action you can dream up:
    https://github.com/dolfdijkstra/gst-foundation/blob/master/gsf-wra/src/main/java/com/fatwire/gst/foundation/controller/A…
    Let me know if I can help!
    Regards,
    Tony

  • How to call another view controller's method from a view controller?

    Hi,
    Iam new to webdynpro . so pls clarify my doubt.
    How to call another view controller's method from a view controller in the same Web Dynpro Component?
    Thanks,
    Krishna

    Hi,
         The methods in a view are only accessible inside same view. you cannot call it outside the view or
         in any other view although its in same component.
         If you want to have a method in both views, then create the method in component controller and
         from there you can access the method any where in whole component.

  • Model View Controller design question

    Hi,
    I am creating a brand new web application, and would like to use the Model View Controller design (using Beans, JSP, and Servlets).
    I am looking design suggestions for handling page forwarding. I don't want to post to a jsp, and I don't want to hard code the name of the next jsp on the forward or in the servlet. I was thinking of having a properties or xml file, which lays out the routing read by the servlet and then dispatched.
    Does anyone have any other design suggestions on the best way to handle routing someone through a web application?

    What you can do is create a servlet that initializes the mappings on startup...create a hashtable of mappings from a file. You'll have to parse the file, so you can either use XML and use a SAX parser, or your own format (name=path? ie. order=/order.jsp), which ever one is simpler for you to use.
    To load the servlet on startup, you specify the load-on-startup parameter in the web descriptor, web.xml:
    <servlet>
         <servlet-name>MappingsLoader</servlet-name>
         <servlet-class>packagename.MappingsLoader</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>
    where load-on-startup number is the order in which it loads the servlet, 1 being first.
    Then once you've created the hashtable, store it in servlet context.
    When you want to forward something, just use a requestdispatcher object and the hashresult to forward the request to another web component (in this case, a jsp).

  • My new iMac has recently had OSX Lion installed on it and now when I start the machine it looks like its updating something every time, and the wireless doesn't work. So I restart and everything is OK - until I have to start up again the next time?

    My new iMac has recently had OSX Lion installed on it and now when I start the machine it looks like its updating something every time, and the wireless doesn't work. So I restart and everything is OK - until I have to start up again the next time - then I have to repeat this again! Any help appreciated.

    I've been having the same issue, but have just discovered something on my own that hasn't been pointed out in any of the forums I've visited.  In what I thought would be a vain attempt to help myself, I went to System Preferences, Users & Groups, and then clicked on Login Items.  I discovered that one of the Items that was listed to open automatically upon login was iTunes Helper and that there was an exclamation point beside it indicating that it was incompatible.  I simply deleted that item and now I don't have the situation you described and my wireless is connected.  Hope this helps!

  • Views dropdown on list view web part doesn't work

    Thank you very much beforehand for any help with this issue, I really can't figure out what is going on.
    So, I have big list (36125 items and about 25 public views there) and view selector on list view web part just stopped respond there couple of days ago. You click on down arrow and nothing happens... There are no any java script errors in browser console,
    there are no any errors in ULS log. Profiler shows that request even is not sent to server when you click it to get list of views.
    At the same time, this web-part works correctly with other lists on this site. 
    Do you have any ideas?

    Hi,
    I understand that the view drop down doesn’t work for a specific list. Can you browse these publish views by manually change the view name in the URL? There are two view drop downs in the ribbon(one under the List tab and one under the browser tab). Are
    they all not working?
    It is a big list, you need to make sure that there are no more than 5000 items in a single view. Only 8 lookups can be added to a view at the same time. You need to make sure that these thresholds.
    For more information about these thresholds, please refer  to this site:
    Manage lists and libraries with many items:
    http://office.microsoft.com/en-us/sharepoint-foundation-help/manage-lists-and-libraries-with-many-items-HA010377496.aspx
    Thanks,
    Entan Ming
    Entan Ming
    TechNet Community Support

  • PSE 10 installed on windows 7 desktop and recently updated on windows laptop.  now PSE doesn't work on either machine.  How can this be fixed?

    PSE 10 installed on windows 7 desktop and recently updated on windows laptop.  now PSE doesn't work on either machine.  How can this be fixed?

    uninstall pse 10 (properly using the adobe uninstaller).
    clean - Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    then try reinstalling using the adobe installation file(s).
    if you see an activation count error while trying to reinstall contact adobe support, https://helpx.adobe.com/contact.html
    and ask for an activation count reset.

  • HT1349 I updated my IGO primo, and now it doesn't work at all. what can you advise me

    I updated my IGO primo, and now it doesn't work at all. what can you advice me now?

    If it's stuck on the Apple logo, you'll have to force it into recovery mode and restore it.  See http://support.apple.com/kb/ht1808.

  • Updated toi IOs5.1, and now imessage doesn´t work.

    i have updated toi IOs5.1, and now imessage doesn´t work.
    what can i do??
    al actualizar el software a 5.1 no funciona imessage.
    como lo soluciono?

    I am having this issue too.  After doing all of the suggested ideas I found online, I am still stuck in "waiting for activiation" mode.  I live out of the country, and my cell phone is not connected to my carrier's network for the next month (so I really have a glorified ipod touch).
    If anyone finds a fix, please pass this info along.
    I have already tried:
    resetting network settings
    log in and out of iMessage/ Facetime
    log in and out of iCloud
    log in and out of iTunes on my phone
    full restore mode on iTunes on my computer
    HELP!!!!!!!

  • Sorry, we've tried to update Premiere Pro cc 2014 but the update failed. Now the option Retry doesn't work. There is other options to solve the problem? Now premiere don't start at all. Thank you in adva

    Sorry, we've tried to update Premiere Pro cc 2014 but the update failed. Now the option Retry doesn't work. There is other options to solve the problem? Now premiere don't start at all. Thank you in adva

    Use the Adobe Cleaner Tool:
    https://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html

  • Hi! I'm using a Macbook Pro, and my photo booth stopped working! I just updated my software yesterday, but it still doesn't work!! The green light does go on though, any suggestions on how to make it work?

    Hi! I'm using a Macbook Pro, and my photo booth stopped working! I just updated my software yesterday, but it still doesn't work!! The green light does go on though, any suggestions on how to make it work?

    In what way is it not working? 
    Please describe in detail all you have attempted to do in order to resolve the issue. 

  • After i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    after i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    I already tried that but it doesn't work. Appears a warning saying: "See the developer to make sure that iPhoto works with this version of OS X. You may need to reinstall the application. Be sure to install all available updates in the application and OS X."

  • After update to iOS6.0.1; auto-lock doesn't work

    After update to iOS6.0.1; auto-lock doesn't work at all

    Which autolock?  Camera?  Calendar?  Game Center?

  • Just installed the newest version. the controller interface doesn't work.

    Just installed the newest version. the controller interface doesn't work.
    Hello, I just installed the newest version from App Store.
    I did not download the drum stuff when open the app for the first time (the check box that you can un-cheack it).
    I open and try to go to the Control interface but it kept saying that it cannot find the layout.
    Please help.
    Thank you.

    Sorry to post in the wrong place.
    I try to move to post but didn't have authorize.
    I guess I will be posting another one in the Garageband for Mac room.

Maybe you are looking for

  • HP LaserJet P2035n Drivers for 64bit XP

    So I tried to use the HP email and live chat support but neither worked because they said my p/n or s/n were invalid and I am pulling them off the printer itself.  The issue I am having is with a HP LaserJet P2035N.  It is hooked to the network and t

  • ABAP Proxy Doesnt work in PI 7.0

    Hi All, We have strange problem with ABAP Proxy under PI system We are getting proxy communication error in PI 7.0 (NOT FROM Business system). After reading a lot of threads & notes, I performed all the necessary checks, but still no luck. --> When I

  • Sending Smartform as an Email Attachment

    Hi All, After executing the FM SO_NEW_DOCUMENT_ATT_SEND_API1, I' m getting sy-subrc as 0. However in receivers table I'm getting the return code 27. Can anybody please suggest what might went wrong. Regards Adi

  • Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. VM29 edge.5.0.0.min.js:56

    Hi, I've come across this error whenever I try to move around the layers on an edge project. As a result the edge animate .an file becomes corrupt and I cannot go back to the file. Some more notes: I created a new file in Edge Animate using the 2014

  • Strange case of ipod mini working but not

    I have an Ipod mini which had died (blank screen, no response to charger etc) and I assumed it was battery related. I fitted a new battery but still no response either when connected to my mac or the USB charger? Purely by chance I placed it in an Al