Monday, March 3, 2014

.repaint() method does not work?
































































































































I am having issues with the repaint method. I overrode the paintComponent method, but when i call repaint with JPanel nothing happens.































































































































My code:
































































































































































































Java Code:








































































































































private class DrawPanel extends JPanel {
private int[] zahlen;

@Override
public void paintComponent (Graphics g){

super.paintComponents(g);
int x = 8;

for(int i = 0; i < zahlen.length; i++){

int zahl = zahlen[i];
g.drawLine(x, 233-(zahl*2), x, 233);
x = x+3;


}
}
}





































































































































































































Java Code:







































































































































String Stringbox1 = (String) sortBox1.getSelectedItem();
String Stringbox2 = (String) sortBox2.getSelectedItem();
String Stringbox3 = (String) sortBox3.getSelectedItem();
String Stringbox4 = (String) sortBox4.getSelectedItem();
String Selectionsort = "Selectionsort";
String Bubblesort = "Bubblesort";
String Insertionsort = "Insertionsort";
String Quicksort = "Quicksort";
String Mergesort = "Mergesort";



if (Stringbox1.equals(Bubblesort)){
Panel1.repaint();
bubbleSort(zahlen);
Panel1.repaint();
} else if (Stringbox1.equals(Selectionsort)){
selectionSort(zahlen);



}
else if (Stringbox1.equals(Insertionsort)){
Panel1.repaint();
insertionSort(zahlen);
Panel1.repaint();
}
else if (Stringbox1.equals(Quicksort)){
Panel1.repaint();
quickSortKomplett(zahlen);
Panel1.repaint();
}
else if (Stringbox1.equals(Mergesort)){
Panel1.repaint();
mergeSort(zahlen);
Panel1.repaint();
}





































































































































if you will need it, i can upload my whole project :)






























































































































































































No comments:

Post a Comment