Hallo,
an der Stelle, wo die Maus geklickt wird, entsteht eine ComboBox. Mein Problem, wenn ich so wie unten stehend Items hinzufügen will, steht immer nur das erste in der Liste, sonst nix.
Per
rufe ich dieses auf.
Was mache ich falsch?
an der Stelle, wo die Maus geklickt wird, entsteht eine ComboBox. Mein Problem, wenn ich so wie unten stehend Items hinzufügen will, steht immer nur das erste in der Liste, sonst nix.
Java:
public class MovedArea {
private JComboBox ValuesArea = null;
private String values;
public String[] splitNames;
private BufferedReader in;
public JComboBox getValuesArea(Point2D mouseClick, int i) {
if (ValuesArea == null) {
ValuesArea = new JComboBox();
ValuesArea.setBackground(Color.red);
ValuesArea.setBounds((int)mouseClick.getX(), (int)mouseClick.getY(), (int)mouseClick.getX(), (int)mouseClick.getY());
ValuesArea.setFont(new Font("Dialog", Font.BOLD, 12));
ValuesArea.setLayout(new BoxLayout(getValuesArea(mouseClick, i), BoxLayout.Y_AXIS));
ValuesArea.addItem("test1");
try {
ValuesArea.removeAll();
in = new BufferedReader(new FileReader("MeineDatei.txt"));
in.readLine();
while ((values = in.readLine()) != null) {
splitNames = values.split("\t");
ValuesArea.addItem(splitNames[i]);
}
}
catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return ValuesArea;
}
}
Per
Java:
ComboBox = movedArea.getValuesArea(Pos, i);
initializeTextArea(ComboBox);
private void initializeTextArea(JComboBox ComboBox) {
paintingComponent.setComboBox(ComboBox);
paintingComponent.repaint();
}
rufe ich dieses auf.
Was mache ich falsch?