package Frame;
import DBAccess.Abfrage;
import DBAccess.Connect;
import Data.Fahrzeug;
import Data.FahrzeugListe;
-------------------
Fehlermeldung:
-------------------
java.lang.NullPointerException
at javax.swing.JTable.prepareRenderer(JTable.java:3731)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:557)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4794)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent.paint(JComponent.java:798)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1312)
at sun.awt.RepaintArea.paint(RepaintArea.java:177)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
at java.awt.Component.dispatchEventImpl(Component.java:3678)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
import DBAccess.Abfrage;
import DBAccess.Connect;
import Data.Fahrzeug;
import Data.FahrzeugListe;
Code:
import Model.AutoTableModel;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Rectangle;
public class AutoVerwaltungFrame extends BaseFrame
{
private JFrame hauptAuswahlFrame;
private JLabel autoVerwLabel = new JLabel();
private JTable autoTable;
private JScrollPane autoTableJsp;
private Connect con;
private Abfrage autoAbfrage;
private Fahrzeug fz;
private FahrzeugListe fahrzeugListe = new FahrzeugListe();
public AutoVerwaltungFrame(JFrame hauptAuswahlFrame, Connect con)
{
this.hauptAuswahlFrame = hauptAuswahlFrame;
this.con = con;
readCarPoolFromDb();
try
{
jbInit();
}
catch(Exception e)
{
System.out.println("Fehler beim Maskenaufbau von AutoVerwaltung");
}
}
public void jbInit() throws Exception
{
autoTable = new JTable(new AutoTableModel(fahrzeugListe));
autoTableJsp = new JScrollPane(autoTable);
autoTableJsp.setBounds(new Rectangle(40, 150, 950, 260));
autoVerwLabel.setText("Auto - Verwaltung:");
autoVerwLabel.setBounds(new Rectangle(35, 35, 295, 60));
autoVerwLabel.setHorizontalTextPosition(SwingConstants.CENTER);
autoVerwLabel.setHorizontalAlignment(SwingConstants.LEFT);
autoVerwLabel.setFont(new Font("Tahoma", 3, 30));
this.getContentPane().add(autoVerwLabel, null);
this.getContentPane().add(autoTableJsp, null);
this.setVisible(true);
this.repaint();
}
private void readCarPoolFromDb()
{
ResultSet result = null;
autoAbfrage = new Abfrage(this.con.getConnection());
result = autoAbfrage.getResult("select * from autopool");
try
{
while(result.next())
{
fz = new Fahrzeug();
fz.setInventarNummer(result.getInt("InventarNummer"));
fz.setMarke(result.getString("Marke"));
fz.setBezeichnung(result.getString("Bezeichnung"));
fz.setLeistung(result.getInt("Leistung"));
fz.setHubraum(result.getInt("Hubraum"));
fz.setFarbe(result.getString("Farbe"));
fz.setPreis(result.getDouble("Preis"));
fz.setZustand(result.getString("Zustand"));
fz.setKmStand(result.getDouble("Km_Stand"));
fz.setErstZulassung(result.getDate("Erstzulassung"));
fz.setExtras(result.getString("Extras"));
fz.setKontakt(result.getString("Kontakt"));
fahrzeugListe.addFahrzeug(fz);
}
}
catch(Exception e)
{
System.out.println("Fehler beim Lesen von Datenbank");
}
}
}
Fehlermeldung:
-------------------
java.lang.NullPointerException
at javax.swing.JTable.prepareRenderer(JTable.java:3731)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:557)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4794)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent.paint(JComponent.java:798)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1312)
at sun.awt.RepaintArea.paint(RepaintArea.java:177)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
at java.awt.Component.dispatchEventImpl(Component.java:3678)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)