Hey leute ich hab folgendes Problem: ich hab versucht einen reender zu schreiben für eine Tabelle dieser zeigt mir jedoch an das diese nur zwei columns hat und ich vermute das des irgendwie mit der anderen tabelle auf dem Frame zu tun hat ich weiß nur nicht warum der fehler auftritt ??
die Form:
und die funktion:
die Form:
Java:
package auftragsverwaltung;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.RowFilter;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
/**
*
* @author xom
*/
public class Bestandsform extends javax.swing.JFrame {
Datenbank db = new Datenbank();
Bestandsfunktionen bf = new Bestandsfunktionen();
DefaultTableModel dtm = new DefaultTableModel();
DefaultTableModel model = new DefaultTableModel();
/**
* Creates new form Bestandsverwaltung
*/
public Bestandsform() {
initComponents();
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
dtm = bf.loadDurationTable();
jTableBestandstabelle.setModel(dtm);
bf.reenderTable(jTableBestandstabelle);
model = bf.loadWebsites(model);
jTableInternettabelle.setModel(model);
Label.setVisible(false);
jTableInternettabelle.setAutoCreateRowSorter(true);
jTableBestandstabelle.setAutoCreateRowSorter(true);
bf.colourCell(jTableInternettabelle);
bf.updateTable(jTableBestandstabelle);
bf.logo(Logo);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
Logo = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jTextfieldSuche = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTableBestandstabelle = new javax.swing.JTable();
jLabel2 = new javax.swing.JLabel();
jTextfieldArtikelbeschreibung = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextfieldEinheit = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jTextfieldMindestmenge = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jTextfieldAktuellerBestand = new javax.swing.JTextField();
jScrollPane2 = new javax.swing.JScrollPane();
jTableInternettabelle = new javax.swing.JTable();
jLabel6 = new javax.swing.JLabel();
jTextfieldInternetadresse = new javax.swing.JTextField();
jButtonHinzufügen = new javax.swing.JButton();
jButtonLöschen = new javax.swing.JButton();
jButtonHinzufügenI = new javax.swing.JButton();
jButtonLöschenI = new javax.swing.JButton();
Label = new javax.swing.JLabel();
jTextfieldPlus = new javax.swing.JButton();
jButtonMinus = new javax.swing.JButton();
jTextfieldBestandsaenderung = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(1376, 607));
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
});
jPanel1.setBackground(new java.awt.Color(0, 0, 0));
jPanel1.setMaximumSize(new java.awt.Dimension(755, 128));
jLabel11.setBackground(new java.awt.Color(0, 0, 0));
jLabel11.setFont(new java.awt.Font("Tahoma", 3, 48)); // NOI18N
jLabel11.setForeground(new java.awt.Color(255, 255, 255));
jLabel11.setText("Bestandsverwaltung");
jLabel7.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel7.setForeground(new java.awt.Color(255, 255, 255));
jLabel7.setText("Suche: ");
jTextfieldSuche.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jTextfieldSuche.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldSucheActionPerformed(evt);
}
});
jTextfieldSuche.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
jTextfieldSucheKeyReleased(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextfieldSuche, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(296, 296, 296))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 514, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(Logo, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextfieldSuche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addContainerGap())
.addComponent(Logo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jTableBestandstabelle.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Artikelnummer", "Artikelbeschreibung", "Einheit", "Mindestmenge", "Aktueller Bestand", "Nachbestellt"
}
) {
Class[] types = new Class [] {
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Boolean.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jTableBestandstabelle.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTableBestandstabelleMouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTableBestandstabelle);
jLabel2.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel2.setText("Artikelbeschreibung:");
jTextfieldArtikelbeschreibung.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jTextfieldArtikelbeschreibung.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldArtikelbeschreibungActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel3.setText("Einheit:");
jTextfieldEinheit.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jTextfieldEinheit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldEinheitActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel4.setText("Mindestmenge:");
jTextfieldMindestmenge.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jTextfieldMindestmenge.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldMindestmengeActionPerformed(evt);
}
});
jTextfieldMindestmenge.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTextfieldMindestmengeKeyTyped(evt);
}
});
jLabel5.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel5.setText("Aktueller Bestand:");
jTextfieldAktuellerBestand.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jTextfieldAktuellerBestand.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldAktuellerBestandActionPerformed(evt);
}
});
jTextfieldAktuellerBestand.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTextfieldAktuellerBestandKeyTyped(evt);
}
});
jTableInternettabelle.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Artikelbeschreibung", "Internetadresse"
}
));
jTableInternettabelle.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTableInternettabelleMouseClicked(evt);
}
});
jScrollPane2.setViewportView(jTableInternettabelle);
jLabel6.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel6.setText("Internetadresse:");
jTextfieldInternetadresse.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jTextfieldInternetadresse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldInternetadresseActionPerformed(evt);
}
});
jTextfieldInternetadresse.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jTextfieldInternetadresseKeyPressed(evt);
}
});
jButtonHinzufügen.setBackground(new java.awt.Color(0, 0, 0));
jButtonHinzufügen.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jButtonHinzufügen.setForeground(new java.awt.Color(255, 255, 255));
jButtonHinzufügen.setText("Hinzufügen");
jButtonHinzufügen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonHinzufügenActionPerformed(evt);
}
});
jButtonLöschen.setBackground(new java.awt.Color(0, 0, 0));
jButtonLöschen.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jButtonLöschen.setForeground(new java.awt.Color(255, 255, 255));
jButtonLöschen.setText("Löschen");
jButtonLöschen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonLöschenActionPerformed(evt);
}
});
jButtonHinzufügenI.setBackground(new java.awt.Color(0, 0, 0));
jButtonHinzufügenI.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jButtonHinzufügenI.setForeground(new java.awt.Color(255, 255, 255));
jButtonHinzufügenI.setText("Hinzufügen");
jButtonHinzufügenI.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonHinzufügenIActionPerformed(evt);
}
});
jButtonLöschenI.setBackground(new java.awt.Color(0, 0, 0));
jButtonLöschenI.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jButtonLöschenI.setForeground(new java.awt.Color(255, 255, 255));
jButtonLöschenI.setText("Löschen");
jButtonLöschenI.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonLöschenIActionPerformed(evt);
}
});
Label.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
Label.setForeground(new java.awt.Color(255, 0, 0));
Label.setText("Label");
jTextfieldPlus.setBackground(new java.awt.Color(0, 0, 0));
jTextfieldPlus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jTextfieldPlus.setForeground(new java.awt.Color(255, 255, 255));
jTextfieldPlus.setText("+");
jTextfieldPlus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextfieldPlusActionPerformed(evt);
}
});
jButtonMinus.setBackground(new java.awt.Color(0, 0, 0));
jButtonMinus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButtonMinus.setForeground(new java.awt.Color(255, 255, 255));
jButtonMinus.setText("-");
jButtonMinus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonMinusActionPerformed(evt);
}
});
jTextfieldBestandsaenderung.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTextfieldBestandsaenderungKeyTyped(evt);
}
});
jLabel8.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
jLabel8.setText("Bestandsänderung:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextfieldInternetadresse, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButtonLöschenI, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonHinzufügenI, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonMinus, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextfieldBestandsaenderung, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextfieldPlus)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Label)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextfieldEinheit, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
.addComponent(jTextfieldAktuellerBestand))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(jTextfieldArtikelbeschreibung, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextfieldMindestmenge, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButtonHinzufügen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonLöschen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 637, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextfieldArtikelbeschreibung, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextfieldMindestmenge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextfieldEinheit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextfieldAktuellerBestand, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextfieldPlus)
.addComponent(jButtonMinus)
.addComponent(jTextfieldBestandsaenderung, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonHinzufügen, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Label))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonLöschen, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextfieldInternetadresse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonHinzufügenI)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonLöschenI))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}// </editor-fold>
private void jTextfieldArtikelbeschreibungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextfieldEinheitActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextfieldMindestmengeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextfieldAktuellerBestandActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextfieldInternetadresseActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButtonHinzufügenActionPerformed(java.awt.event.ActionEvent evt) {
try {
bf.addDurationen(jTableBestandstabelle, jTextfieldArtikelbeschreibung, jTextfieldEinheit,
jTextfieldMindestmenge, jTextfieldAktuellerBestand, Label);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Bestandsform.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButtonLöschenActionPerformed(java.awt.event.ActionEvent evt) {
try {
bf.deleteDuration(jTableBestandstabelle);
} catch (SQLException ex) {
Logger.getLogger(Bestandsform.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButtonHinzufügenIActionPerformed(java.awt.event.ActionEvent evt) {
try {
bf.addWebsite(jTableBestandstabelle, jTableInternettabelle, jTextfieldArtikelbeschreibung,
jTextfieldInternetadresse, Label);
} catch (SQLException ex) {
Logger.getLogger(Bestandsform.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButtonLöschenIActionPerformed(java.awt.event.ActionEvent evt) {
bf.deleteWebsite(jTableInternettabelle);
}
private void jTextfieldInternetadresseKeyPressed(java.awt.event.KeyEvent evt) {
}
private void jTableBestandstabelleMouseClicked(java.awt.event.MouseEvent evt) {
int i = jTableBestandstabelle.getSelectedRow();
String artikelBeschreibung = (String) (jTableBestandstabelle.getModel().getValueAt(i, 1));
if (artikelBeschreibung.equals("-")) {
artikelBeschreibung = "";
}
jTextfieldArtikelbeschreibung.setText(artikelBeschreibung);
String einheit = (String) (jTableBestandstabelle.getModel().getValueAt(i, 2));
jTextfieldEinheit.setText(einheit);
int mindestMenge = (int) (jTableBestandstabelle.getModel().getValueAt(i, 3));
String m = Integer.toString(mindestMenge);
jTextfieldMindestmenge.setText(m);
int aktuellerBestand = (int) (jTableBestandstabelle.getModel().getValueAt(i, 4));
String a = Integer.toString(aktuellerBestand);
jTextfieldAktuellerBestand.setText(a);
}
private void jTextfieldSucheActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextfieldSucheKeyReleased(java.awt.event.KeyEvent evt) {
dtm = (DefaultTableModel) jTableBestandstabelle.getModel();
DefaultTableModel model = (DefaultTableModel) jTableInternettabelle.getModel();
TableRowSorter<DefaultTableModel> tr
= new TableRowSorter<DefaultTableModel>(dtm);
TableRowSorter<DefaultTableModel> trs
= new TableRowSorter<DefaultTableModel>(model);
String suche = jTextfieldSuche.getText();
jTableBestandstabelle.setRowSorter(tr);
jTableInternettabelle.setRowSorter(trs);
tr.setRowFilter(RowFilter.regexFilter(suche));
trs.setRowFilter(RowFilter.regexFilter(suche));
}
private void jTableInternettabelleMouseClicked(java.awt.event.MouseEvent evt) {
bf.getCell(jTableInternettabelle);
}
private void jTextfieldPlusActionPerformed(java.awt.event.ActionEvent evt) {
int aenderung;
if (jTextfieldBestandsaenderung.getText().length() == 0) {
aenderung = 1;
} else {
aenderung = Integer.parseInt(jTextfieldBestandsaenderung.getText());
}
bf.plus(jTableBestandstabelle, aenderung, jTextfieldAktuellerBestand, Label);
}
private void jButtonMinusActionPerformed(java.awt.event.ActionEvent evt) {
int aenderung;
if (jTextfieldBestandsaenderung.getText().length() == 0) {
aenderung = 1;
} else {
aenderung = Integer.parseInt(jTextfieldBestandsaenderung.getText());
}
bf.minus(jTableBestandstabelle, aenderung, jTextfieldAktuellerBestand, Label);
}
private void jTextfieldAktuellerBestandKeyTyped(java.awt.event.KeyEvent evt) {
char enter = evt.getKeyChar();
if (!(Character.isDigit(enter))) {
evt.consume();
}
}
private void jTextfieldMindestmengeKeyTyped(java.awt.event.KeyEvent evt) {
char enter = evt.getKeyChar();
if (!(Character.isDigit(enter))) {
evt.consume();
}
}
private void jTextfieldBestandsaenderungKeyTyped(java.awt.event.KeyEvent evt) {
char enter = evt.getKeyChar();
if (!(Character.isDigit(enter))) {
evt.consume();
}
}
private void formMouseClicked(java.awt.event.MouseEvent evt) {
jTextfieldArtikelbeschreibung.setText(null);
jTextfieldEinheit.setText(null);
jTextfieldMindestmenge.setText(null);
jTextfieldAktuellerBestand.setText(null);
jTextfieldBestandsaenderung.setText(null);
}
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify
private javax.swing.JLabel Label;
private javax.swing.JLabel Logo;
private javax.swing.JButton jButtonHinzufügen;
private javax.swing.JButton jButtonHinzufügenI;
private javax.swing.JButton jButtonLöschen;
private javax.swing.JButton jButtonLöschenI;
private javax.swing.JButton jButtonMinus;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable jTableBestandstabelle;
private javax.swing.JTable jTableInternettabelle;
private javax.swing.JTextField jTextfieldAktuellerBestand;
private javax.swing.JTextField jTextfieldArtikelbeschreibung;
private javax.swing.JTextField jTextfieldBestandsaenderung;
private javax.swing.JTextField jTextfieldEinheit;
private javax.swing.JTextField jTextfieldInternetadresse;
private javax.swing.JTextField jTextfieldMindestmenge;
private javax.swing.JButton jTextfieldPlus;
private javax.swing.JTextField jTextfieldSuche;
// End of variables declaration
}
und die funktion:
Java:
public void reenderTable(JTable jTableBestandstabelle) {
jTableBestandstabelle.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
System.out.println(column);
if (column == 4) {
int akt = (Integer) table.getModel().getValueAt(row, column);
int min = (Integer) table.getModel().getValueAt(row, column-1);
Boolean x = (Boolean) table.getValueAt(row, 5);
if (akt == min && x == false) {
c.setBackground(Color.ORANGE);
c.setForeground(Color.BLACK);
}
if (akt < min && min != 0 && x == false) {
c.setBackground(Color.RED);
c.setForeground(Color.BLACK);
}else {
c.setBackground(Color.WHITE);
c.setForeground(Color.BLACK);
}
}
return c;
}
});
}