G
Guest
Gast
Code:
public class ausgabe
{
public static void ausgabefunktion()
{
}
}
Wie rufe ich in der methode ausgabefunktion die methode create der folgenden klasse auf? 1000 DAnk schonmal Vorab!
Code:
public class balkendiagramm
{
public JLabel create(int wert1, int wert2, int wert3, int wert4, int wert5, int wert6, int wert7, int wert8, int wert9)
{
JLabel hlabel2 = new JLabel(); //(hintergrund2);
hlabel2.setSize(500, 300);
hlabel2.setLocation(300,0);
//Das Maximum der 9 zahlen wird errechnet
float max = Math.max(wert1,Math.max(wert2,Math.max(wert3,Math.max(wert4,Math.max(wert5, Math.max(wert6, Math.max(wert7, Math.max(wert8,wert9))))))));
//Die Balkenlänge ergibt sich aus dem Quotienten wert/max
//mal der festgelegten maximalen Breite von 490 Pixeln
//Sollte ein negativer Gesamtwert einer Kategorie berechnet werden, so ist kein Balken sichtbar
float tf1size = wert1/max*490;
float tf2size = wert2/max*490;
float tf3size = wert3/max*490;
float tf4size = wert4/max*490;
float tf5size = wert5/max*490;
float tf6size = wert6/max*490;
float tf7size = wert7/max*490;
float tf8size = wert8/max*490;
float tf9size = wert9/max*490;
JTextField tf1 = new JTextField("Lebensmittel");
tf1.setSize((int)tf1size,20);
tf1.setLocation(0,12);
tf1.setBackground(Color.GREEN);
hlabel2.add(tf1);
JTextField tf2 = new JTextField("KFZ");
tf2.setSize((int)tf2size,20);
tf2.setLocation(0,44);
tf2.setBackground(Color.BLUE);
hlabel2.add(tf2);
JTextField tf3 = new JTextField("Wohnen");
tf3.setSize((int)tf3size,20);
tf3.setBackground(Color.RED);
tf3.setLocation(0,76);
hlabel2.add(tf3);
JTextField tf4 = new JTextField("Bildung");
tf4.setSize((int)tf4size,20);
tf4.setBackground(Color.CYAN);
tf4.setLocation(0,108);
hlabel2.add(tf4);
JTextField tf5 = new JTextField("Freizeit");
tf5.setSize((int)tf5size,20);
tf5.setBackground(Color.ORANGE);
tf5.setLocation(0,140);
hlabel2.add(tf5);
JTextField tf6 = new JTextField("Haushaltswaren");
tf6.setSize((int)tf6size,20);
tf6.setBackground(Color.PINK);
tf6.setLocation(0,172);
hlabel2.add(tf6);
JTextField tf7 = new JTextField("Kleidung");
tf7.setSize((int)tf7size,20);
tf7.setBackground(Color.MAGENTA);
tf7.setLocation(0,204);
hlabel2.add(tf7);
JTextField tf8 = new JTextField("Verdienst");
tf8.setSize((int)tf8size,20);
tf8.setBackground(Color.YELLOW);
tf8.setLocation(0,236);
hlabel2.add(tf8);
JTextField tf9 = new JTextField("Gesamtbetrag");
tf9.setSize((int)tf9size,20);
tf9.setBackground(Color.WHITE);
tf9.setLocation(0,268);
hlabel2.add(tf9);
return hlabel2;
}
}