dimanche 17 mai 2015

Swing Oberfläche rekusiv updaten mit updateUi()

Hallo zusammen,

ich habe eine Oberfläche, die sich beim ändern des Models rekursiv updatet. Dazu habe ich eine View mit der Funktion update()

Java Code:

  1.  
  2.  
  3. [...]
  4.  
  5. public void update ()
  6. {
  7. //Oberfläche updaten
  8. updateChilds (_mainpanel);
  9. }
  10.  
  11. public void updateChilds (Component comp)
  12. {
  13.  
  14. if (comp == null) return;
  15. if (comp instanceof Container)
  16. {
  17. Container con = (Container) comp;
  18. Component[] comps = con.getComponents();
  19. for (int i = 0; i<comps.length; i++)
  20. {
  21. Component c = comps[i];
  22. if (c instanceof JComponent) {
  23. jc.updateUI();
  24. }
  25. updateChilds(c);
  26. }
  27. return;
  28.  
  29. }


Dabei bekomme ich einen Fehler:

Code:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
        at javax.swing.plaf.basic.BasicTabbedPaneUI.tabForCoordinate(BasicTabbedPaneUI.java:1506)
        at javax.swing.plaf.basic.BasicTabbedPaneUI.setRolloverTab(BasicTabbedPaneUI.java:575)
        at javax.swing.plaf.basic.BasicTabbedPaneUI.access$2000(BasicTabbedPaneUI.java:54)
        at javax.swing.plaf.basic.BasicTabbedPaneUI$Handler.mouseEntered(BasicTabbedPaneUI.java:3627)
        at java.awt.Component.processMouseEvent(Component.java:6534)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
        at java.awt.Component.processEvent(Component.java:6290)
        at java.awt.Container.processEvent(Container.java:2234)
        at java.awt.Component.dispatchEventImpl(Component.java:4881)
        at java.awt.Container.dispatchEventImpl(Container.java:2292)
        at java.awt.Component.dispatchEvent(Component.java:4703)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
        at java.awt.LightweightDispatcher.retargetMouseEnterExit(Container.java:4686)
        at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4665)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4514)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
        at java.awt.Container.dispatchEventImpl(Container.java:2278)
        at java.awt.Window.dispatchEventImpl(Window.java:2739)
        at java.awt.Component.dispatchEvent(Component.java:4703)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
        at java.awt.EventQueue.access$400(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:697)
        at java.awt.EventQueue$3.run(EventQueue.java:691)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.awt.EventQueue$4.run(EventQueue.java:719)
        at java.awt.EventQueue$4.run(EventQueue.java:717)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Dann wollte ich debuggen, und mein Eclipse stürzt ab und der Bildschirm friert ein. Also hab ich die Updatefunktion mal herausgenommen und ein return rein mit einem Haltepunkt versehen:

Java Code:

  1. public void update ()
  2. {
  3. //also hier passiert eigentlich nichts, trotzdem friert der Bildschirm ein, aber nur im Debugmodus
  4. return;
  5. }


Hat jemand eine Idee, woran das liegen könnte ?

Vielen Dank !

SignIn


Swing Oberfläche rekusiv updaten mit updateUi()

0 commentaires:

Enregistrer un commentaire