Java - Aplicacion con problemas, necesito ayuda pleasee

 
Vista:

Aplicacion con problemas, necesito ayuda pleasee

Publicado por Oriana (30 intervenciones) el 29/11/2006 20:49:40
Buenas tardes, estoy haciendo una aplicacion standalone la cual le estoy tratando de colocar un componente JTree, ya coloqué la estructura del componente en la aplicación, pero cuando selecciono alguno de los nodos no resalta el nodo seleccionado hasta despues que se hace una actualización de la ventana, bien sea minimizar maximizar o mover el scroll, no tengo idea por qué sucede esto, si alguien puede ayudarme se lo agradeceré, a continuación coloco el código que coloqué...

/*
* Ärbol de Contenido
*/
DefaultMutableTreeNode titulos = new DefaultMutableTreeNode("Titulo");
DefaultMutableTreeNode capitulos;
DefaultMutableTreeNode temas;
for(int childIndex=1; childIndex<botonesmenu; childIndex++)
{
capitulos = new DefaultMutableTreeNode("Capitulo " + childIndex);
titulos.add(capitulos);
for(int grandChildIndex=1; grandChildIndex<botonesmenu; grandChildIndex++)
{
temas = new DefaultMutableTreeNode("Tema " + childIndex +"." + grandChildIndex);
capitulos.add(temas);
}
}
JTree arbol = new JTree(titulos);
arbol.addTreeSelectionListener(this);

JScrollPane scrollArbol = new JScrollPane(arbol);
scrollArbol.setOpaque(true);

addComponente(scrollArbol,3,200,172,248);

el otro detalle que al extender la clase con el componente TreeSelectionListener la cual quedó de esta forma : public class Aplicacion extends FondoAplicacion implements TreeSelectionListener{
produce un par de errores que dicen:
- the type Aplicacion must implement the inherited abstract method TreeSelectionListener.ValueChanged
(TreeSelectionEvent)
-the serializable class Aplicacion does not declarate a static final SerialVersionUID field of type long

ya le eche un bistazo a las librerías y está aparentemente bien, eso solo sale si no coloco lo siguiente:

public void valueChanged(TreeSelectionEvent event)
{
scrollArbol.setText("Current Selection: " +arbol.getLastSelectedPathComponent().toString());
}

en el caso de que coloco eso, no me reconoce ni el scrollArbol ni el arbol y me produce este error al correr la aplicacion pero de igual manera esta corre

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
scrollArbol cannot be resolved

at Aplicacion.valueChanged(Aplicacion.java:288)
at javax.swing.JTree.fireValueChanged(Unknown Source)
at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source)
at javax.swing.JTree.setSelectionPath(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelectionImpl(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.AWTEventMulticaster.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.pumpOneEventForHierarchy(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)

La verdad que soy principiante en esto, trato de entender pero no lo logro...
Gracias!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder