Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implement AbstractTableModel Tablemodel Jtable

 
antonio espinosa
Ranch Hand
Posts: 30
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello wise coders!.would you mind helping me this time ?.

i'm working on tables so i'm reading java tutorials and i want to implement my own model as oracle recomend in this link Implement AbsctractTableModel.

the trouble is that i need my own data and columnames provided by a resultset BUT i cant set the results to this new implementation of abstracttablemodel returns me the following error .


i've tried the following:

  • at the enclosing class for setting the column names and data




  • at the innerclass



  • then i set the model to a table



  • i execute and get this!:

  • (the application runs , but the frame isn't painted correctly, when i pass the mouse over the components starts paiting!)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at cobroconjava.InicioCobro$ModeloPaCobrar.getColumnClass(InicioCobro.java:266)
    at javax.swing.JTable.getColumnClass(JTable.java:2701)
    at javax.swing.JTable.getCellRenderer(JTable.java:5686)
    at javax.swing.plaf.synth.SynthTableUI.paintCell(SynthTableUI.java:683)
    at javax.swing.plaf.synth.SynthTableUI.paintCells(SynthTableUI.java:581)
    at javax.swing.plaf.synth.SynthTableUI.paint(SynthTableUI.java:365)
    at javax.swing.plaf.synth.SynthTableUI.update(SynthTableUI.java:276)
    at javax.swing.JComponent.paintComponent(JComponent.java:778)
    at javax.swing.JComponent.paint(JComponent.java:1054)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JViewport.paint(JViewport.java:731)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5228)
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482)
    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
    at javax.swing.JComponent.paint(JComponent.java:1040)
    at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
    at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
    at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
    at java.awt.Container.paint(Container.java:1967)
    at java.awt.Window.paint(Window.java:3877)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
    at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
    at java.awt.EventQueue.access$000(EventQueue.java:102)
    at java.awt.EventQueue$3.run(EventQueue.java:662)
    at java.awt.EventQueue$3.run(EventQueue.java:660)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)


    i guess how implement correctly the constructor of MYOWNCUSTOMMODEL? or something else is missing?;

    thank you in advance!
     
    Kemal Sokolovic
    Bartender
    Posts: 825
    5
    Java Python Ruby
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The code you provided is such a mess, that I don't think anyone will even try to analyze it. At least I won't.
    I would check this first Code Conventions for Java Programming Language before jumping into problems you're posting.

    Cheers!
     
    Michael Dunn
    Ranch Hand
    Posts: 4632
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    > at cobroconjava.InicioCobro$ModeloPaCobrar.getColumnClass(InicioCobro.java:266)

    well, what's there?
     
    antonio espinosa
    Ranch Hand
    Posts: 30
    Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Michael Dunn wrote:> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    > at cobroconjava.InicioCobro$ModeloPaCobrar.getColumnClass(InicioCobro.java:266)

    well, what's there?



    it's an overriden method of abstracttablemodel , sorry i translated the classes and variables names to English .
    ModeloPaCobrar=MYCUSTOMMODEL
     
    antonio espinosa
    Ranch Hand
    Posts: 30
    Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Kemal Sokolovic wrote:The code you provided is such a mess, that I don't think anyone will even try to analyze it. At least I won't.
    I would check this first Code Conventions for Java Programming Language before jumping into problems you're posting.

    Cheers!


    thank you , i've already known of this but i have been busy for reading the conventions.rigth now i'm more concern in learning java classes , methods and tricks than writting fancy, because i don't share code with any body.Very soon i'll be reading the java conventions because i know the importance of this.
     
    Michael Dunn
    Ranch Hand
    Posts: 4632
     
    antonio espinosa
    Ranch Hand
    Posts: 30
    Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thank you very much my friend. that was the problem i also removed the method and runs without problems, but is that recommended?.

    you are very kind and helpful.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic