aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Implement AbstractTableModel Tablemodel Jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Implement AbstractTableModel Tablemodel Jtable" Watch "Implement AbstractTableModel Tablemodel Jtable" New topic
Author

Implement AbstractTableModel Tablemodel Jtable

antonio espinosa
Ranch Hand

Joined: Jul 30, 2012
Posts: 30

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

    Joined: Jun 19, 2010
    Posts: 825
        
        5

    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!


    The quieter you are, the more you are able to hear.
    Michael Dunn
    Ranch Hand

    Joined: Jun 09, 2003
    Posts: 4632
    > 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

    Joined: Jul 30, 2012
    Posts: 30

    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

    Joined: Jul 30, 2012
    Posts: 30

    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

    Joined: Jun 09, 2003
    Posts: 4632

    http://www.coderanch.com/t/345807/GUI/java/tablemodel-getcolumnclass-method-produces-null
    antonio espinosa
    Ranch Hand

    Joined: Jul 30, 2012
    Posts: 30

    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Implement AbstractTableModel Tablemodel Jtable
     
    Similar Threads
    Java Advanced Imaging throwing AccessControlExceptions when I try to perform a rendering operation
    populate data from database into a jtable
    regarding JTable data
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    updating database cause error