hallo, ich hoffe ihr könnt mir helfen, werke schon seit tagen an meinem matrix-berrechnungsprogramm und es will einfach nicht
keine angst, der code wirkt nur so lang, ist er aber beim durcharbeiten nicht!
hier das problem:
das programm wirft mir eine NullPointerException bei der zeile:
der ausschnitt aus Matrixoperations:
und hier die klasse wegmatrix
zum schluss noch die klasse adjazents_marix:
diese fehlermeldungen bekomme ich:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at MeinContr.getWayMatrix(MeinContr.java:82)
at MainFrame$4.actionPerformed(MainFrame.java:327)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(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)
ich hoffe ich hab nichts vergessen
und ich hoffe ihr könnt mir da helfen
thx a lot!!!
lg
keine angst, der code wirkt nur so lang, ist er aber beim durcharbeiten nicht!
hier das problem:
Code:
public class MeinContr implements Controller {
private JButton matrix[][];
long[][] usematrix;
long[][] matrix1;
Matrixoperations opts;
private Matrix ma;
public int getSize() {
return ma.getIVertexRate();
}
public long[][] JButtonToLong(JButton[][] jbField){
int size = jbField.length;
usematrix = new long[size][size];
for (int i = 0; i < size; i++){
for (int j = 0; j < size; j++){
if (jbField[i][j].getText().equals("-")){
this.usematrix[i][j]=0;
ma.matrix[i][j]=0;
}
else {
this.usematrix[i][j] = Long.parseLong(jbField[i][j].getText());
ma.matrix[i][j] = Long.parseLong(jbField[i][j].getText());
}
}
}
return usematrix;
}
public void setMatrixButton(JButton jbField[][], int x, int y) {
if (jbField[x][y].getText() == "1") {
jbField[x][y].setText("0");
jbField[y][x].setText("0");
} else {
jbField[x][y].setText("1");
jbField[y][x].setText("1");
}
}
public void setModel(Matrix newModel) {
this.ma = newModel;
}
public String getWayMatrix(JButton[][] jbField) {
long[][] tmp;
StringBuffer Kg = new StringBuffer();
tmp=opts.getWegmatrix(JButtonToLong(jbField));
Kg.append("Wegmatrix:\n");
for(int i = 0;i<tmp.length;i++){
for(int j = 0;j<tmp.length;j++){
Kg.append(" ").append(tmp[i][j]).append(" ");
}
Kg.append("\n");
}
String s = Kg.toString();
return "TEST!!!!:\n "+s;
}
das programm wirft mir eine NullPointerException bei der zeile:
Code:
tmp=opts.getWegmatrix(JButtonToLong(jbField));
der ausschnitt aus Matrixoperations:
Code:
public class Matrixoperations
{
private Adjazentsmatrix Adjazentsmatrix;
private Wegmatrix Wegmatrix;
private Distanzmatrix Distanzmatrix;
public long[][] getWegmatrix(long[][] matrix){
int size = matrix[0].length;
Adjazentsmatrix = new Adjazentsmatrix(size);
Adjazentsmatrix.berchenA_matrizen(matrix);
Wegmatrix = new Wegmatrix(size, Adjazentsmatrix);
return (Wegmatrix.getWegmatrix());
}
und hier die klasse wegmatrix
Code:
public class Wegmatrix extends Matrix
{
Adjazentsmatrix amatrix;
public Wegmatrix(int size, Adjazentsmatrix adja)
{
super(size);
amatrix = adja;
nullMatrix();
}
public long[][] getWegmatrix()
{
int hupfmatrix[][];
int höhe = amatrix.getHöhe();
int size = getSize();
for (int i = 0; i <= höhe; i++)
{
hupfmatrix = einserhupfMatrix(amatrix.getA_matrizen(i), getMatrix());
for (int zeile = 0; zeile < size; zeile++)
{
for (int spalte = 0; spalte < size; spalte++)
{
if (getoneValue(zeile, spalte) == 0 && hupfmatrix[zeile][spalte] > 0)
{
setoneValue(zeile, spalte, 1);
}
}
}
}
return (getMatrix());
}
}
zum schluss noch die klasse adjazents_marix:
Code:
public class Adjazentsmatrix extends Matrix
{
private Matrix a_matrizen[];
private int höhe;
public Adjazentsmatrix(int size)
{
super(size);
nullMatrix();
}
private void initializeA_matrizen(){
int size;
int i;
size = getSize();
a_matrizen = new Matrix[size];
for (i = 0; i < size; i++){
a_matrizen[i] = new Matrix(size);
if (i == 0)
{
a_matrizen[i].einheitsMatrix();
}
else
if (i == 1)
{
a_matrizen[i].setMatrix(getMatrix());
}
}
}
private void setAmatrix(long tmp[][]){
setMatrix(tmp);
}
private void setA_matrizen(long bla[][], int höhe){
a_matrizen[höhe].setMatrix(bla);
}
public long[][] getA_matrizen(int höhe){
return (a_matrizen[höhe].getMatrix());
}
public void berchenA_matrizen(long tmp[][]){
int i;
int size;
höhe=1;
setAmatrix(tmp);
size = getSize();
initializeA_matrizen();
setA_matrizen(getMatrix(), 1);
for (i = 2; i < size; i++)
{
a_matrizen[i].setMatrix(getMatrix());
a_matrizen[i].multipliziereDich(a_matrizen[i - 1]);
höhe++;
if (a_matrizen[i].nullCheck() != 1)
{
if (i == 2)
{
a_matrizen[i].unendlicheMatrix();
i = size;
}
else
{
i = size;
}
}
else
if (a_matrizen[i].nullSprung(a_matrizen[i - 1]) != 1)
{
i = size;
}
}
}
public int getHöhe(){
return (höhe);
}
public int nullsprungtest(int a, int b) {
int y;
y = a_matrizen[a].nullSprung(a_matrizen[b]);
return (y);
}
public int nulltest(int a){
int y;
y = a_matrizen[a].nullCheck();
return (y);
}
public int[][] einserhupmatrixftest(int a, int b){
int y[][];
y = a_matrizen[a].einserhupfMatrix(getA_matrizen(a), getA_matrizen(b));
return (y);
}
}
diese fehlermeldungen bekomme ich:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at MeinContr.getWayMatrix(MeinContr.java:82)
at MainFrame$4.actionPerformed(MainFrame.java:327)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(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)
ich hoffe ich hab nichts vergessen
und ich hoffe ihr könnt mir da helfen
thx a lot!!!
lg