Hallo,
ich habe eine Frage bezüglich meines Codes
Nun zu meiner Frage: Ist es möglich, da wo die Spalten befüllt werden, z.B. die grüne Farbe anzuzeigen, anstatt dass man grün schreibt? Ich hab schon im Internet gesucht, aber leider ohne Erfolg. An dem Code ist alles gut, der klappt auch soweit.
MfG
ich habe eine Frage bezüglich meines Codes
Code:
private void addDefenseColumns(TableView<Defense> _defenseTable){
// Add columns
TableColumn<Defense, String> de = new TableColumn<Defense, String>("Defence");
de.setCellValueFactory(new PropertyValueFactory<Defense, String>("de"));
TableColumn<Defense, String> des = new TableColumn<Defense, String>("Description");
des.setCellValueFactory(new PropertyValueFactory<Defense, String>("des"));
TableColumn<Defense, String> level = new TableColumn<Defense, String>("Level");
level.setCellValueFactory(new PropertyValueFactory<Defense, String>("level"));
TableColumn<Defense, String> price = new TableColumn<Defense, String>("Price");
price.setCellValueFactory(new PropertyValueFactory<Defense, String>("price"));
TableColumn<Defense, String> cd = new TableColumn<Defense, String>("Cooldown");
cd.setCellValueFactory(new PropertyValueFactory<Defense, String>("cd"));
TableColumn<Defense, String> color = new TableColumn<Defense, String>("Color");
color.setCellValueFactory(new PropertyValueFactory<Defense, String>("color"));
TableColumn<Defense, String> range = new TableColumn<Defense, String>("Range");
range.setCellValueFactory(new PropertyValueFactory<Defense, String>("range"));
TableColumn<Defense, String> damage = new TableColumn<Defense, String>("Damage");
damage.setCellValueFactory(new PropertyValueFactory<Defense, String>("damage"));
TableColumn<Defense, String> sr = new TableColumn<Defense, String>("Slowrate");
sr.setCellValueFactory(new PropertyValueFactory<Defense, String>("sr"));
TableColumn<Defense, String> st = new TableColumn<Defense, String>("Slowtimes");
st.setCellValueFactory(new PropertyValueFactory<Defense, String>("st"));
TableColumn<Defense, String> splash = new TableColumn<Defense, String>("Splash");
splash.setCellValueFactory(new PropertyValueFactory<Defense, String>("splash"));
TableColumn<Defense, String> sdr = new TableColumn<Defense, String>("Radius Splash Damage Reduction");
sdr.setCellValueFactory(new PropertyValueFactory<Defense, String>("sdr"));
_defenseTable.getColumns().addAll(de, des, level, price, cd, color, range,
damage, sr, st, splash, sdr);
}
//create the data for defense
private ObservableList<Defense> getDefenseData(TableView<Defense> _defenseTable){
ObservableList<Defense> data = _defenseTable.getItems();
data.addAll(new Defense("Small", "–", "1", "50", "650", "green", "1.75", "25", "–", "–", "–", "–"),
new Defense("Small", "–", "2", "100", "650", "blue", "2.0", "50", "–", "–", "–", "–"),
new Defense("Small", "–", "3", "1000", "650", "red", "2.25", "250", "–", "–", "–", "–"),
new Defense("Small", "–", "4", "3000", "650", "yellow", "2.5", "1000", "–", "–", "–", "–"),
new Defense("Frost", "slows target", "1", "100", "750", "green", "1.75", "25", "0.3", "2000", "–", "–"),
new Defense("Frost", "slows target", "2", "200", "800", "blue", "2.25", "50", "0.35", "2000", "–", "–"),
new Defense("Frost", "slows target", "3", "400", "850", "red", "2.5", "75", "0.45", "2500", "–", "–"),
new Defense("Frost", "slows multiple targets", "4", "3000", "900", "yellow", "2.5", "100", "0.5", "2500", "1.25", "0.7"),
new Defense("Swash", "attacks multiple targets", "1", "250", "750", "green", "2.0", "50", "–", "–", "1.75", "0.7"),
new Defense("Swash", "attacks multiple targets", "2", "750", "600", "blue", "2.25", "200", "–", "–", "1.75", "0.7"),
new Defense("Swash", "attacks multiple targets", "3", "3000", "500", "red", "2.75", "400", "–", "–", "1.75", "0.6"),
new Defense("Swash", "attacks multiple targets", "4", "500", "500", "yellow", "3.0", "1100", "–", "–", "1.75", "0.5"),
new Defense("Boom", "attacks multiple targets", "1", "1000", "3750", "green", "2.5", "1000", "–", "–", "1.25", "0.8"),
new Defense("Boom", "attacks multiple targets", "2", "3000", "3750", "blue", "3.0", "2500", "–", "–", "1.25", "0.8"),
new Defense("Boom", "attacks multiple targets", "3", "7500", "3250", "red", "3.5", "7500", "–", "–", "1.5", "0.7"),
new Defense("Boom", "attacks multiple targets", "4", "15000", "3000", "yellow", "4.0", "15000", "–", "–", "1.75", "0.6"),
new Defense("Tempo", "–", "1", "1000", "450", "green", "2.5", "225", "–", "–", "–", "–"),
new Defense("Tempo", "–", "2", "3000", "350", "blue", "2.75", "450", "–", "–", "–", "–"),
new Defense("Tempo", "–", "3", "7500", "250", "red", "3.0", "1100", "–", "–", "–", "–"),
new Defense("Tempo", "–", "4", "15000", "150", "yellow", "3.25", "1800", "–", "–", "–", "–"),
new Defense("Big Bang", "–", "1", "20000", "5000", "green", "5.0", "25000", "–", "–", "–", "–"),
new Defense("Big Bang", "–", "2", "50000", "2500", "yellow", "7.5", "40000", "–", "–", "–", "–"));
return data;
}
Nun zu meiner Frage: Ist es möglich, da wo die Spalten befüllt werden, z.B. die grüne Farbe anzuzeigen, anstatt dass man grün schreibt? Ich hab schon im Internet gesucht, aber leider ohne Erfolg. An dem Code ist alles gut, der klappt auch soweit.
MfG