salve a tutti.
Ho creato una interfaccia grafica in java tramite Swing. L'utente può cambiare tema cliccando su un jtree.
applicando agli oggetti il metodo .updateUI() sembra funziona,ma con per ovvi motivi cerco di utilizzare updateComponentTreeUI().Oltre al fatto che un jdialog interno al programma non cambia d'aspetto(e forse è proprio lui il problema), mi restituisce il seguente errore in esecuzione (su eclipse). :master:
codice:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException 	
at javax.swing.plaf.basic.BasicTreeUI.isToggleEvent(Unknown Source) 	
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source) 	
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source) 
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source) 	
at java.awt.Component.processMouseEvent(Unknown Source) 	
at javax.swing.JComponent.processMouseEvent(Unknown Source) 	
at java.awt.Component.processEvent(Unknown Source) 	
at java.awt.Container.processEvent(Unknown Source) 	
at java.awt.Component.dispatchEventImpl(Unknown Source) 	
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 	
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 	
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 	
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 	
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Window.dispatchEventImpl(Unknown Source) 	
at java.awt.Component.dispatchEvent(Unknown Source) 	
at java.awt.EventQueue.dispatchEvent(Unknown Source) 	
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 	
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 	
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 	
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 	
at java.awt.EventDispatchThread.run(Unknown Source)
per trovare il riferimento implicito null ho modificato il metodo della libreria java SwingUtilities in questo modo:
codice:
public static void  updateComponentTreeUI(Component c) {
		if(c==null) return;
		try{
        updateComponentTreeUI0(c);
        c.invalidate();
        c.validate();
        c.repaint();
		}
        catch(Exception e){
        	System.out.println("beccato");
        }
    }

   
    private static void updateComponentTreeUI0(Component c) {
    	if (c==null) return;
    	try{
        if (c instanceof JComponent) {
            JComponent jc = (JComponent) c;
            jc.updateUI(); //aggiornaUI principale
            JPopupMenu jpm =jc.getComponentPopupMenu(); 
            if(jpm != null && jpm.isVisible() && jpm.getInvoker() == jc) {
                updateComponentTreeUI(jpm);
            }
        }
       
        Component[] children = null;
        if (c instanceof JMenu) {
            children = ((JMenu)c).getMenuComponents();
        }
        else if (c instanceof Container) {
            children = ((Container)c).getComponents();
        }
        if (children != null) {
            for(int i = 0; i < children.length; i++) {
                updateComponentTreeUI0(children[i]);
            }
        }
    	}
    	catch(Exception e){
    		System.out.println("beccato");
    	}
    }
ma non ne esco..