java - Columns not appearing when TableView is static -
this question has answer here:
i have question tableview element in javafx.
when try use , add columns it, works fine, if set static (need access stage) columns not appearing @ all.
my code looks (extracts):
@fxml private static tableview<datensatz> table = new tableview(); @override public void initialize(url url, resourcebundle rb) { erstelletabelle(); } private static void erstelletabelle() { tablecolumn namecolumn = new tablecolumn("name"); namecolumn.setcellvaluefactory(new propertyvaluefactory<>("name")); tablecolumn handynrcolumn = new tablecolumn("handynummer"); handynrcolumn.setcellvaluefactory(new propertyvaluefactory<>("handynummer")); tablecolumn rechnungsdatumcolumn = new tablecolumn("rechnungsdatum"); rechnungsdatumcolumn.setcellvaluefactory(new propertyvaluefactory<>("rechnungsdatum")); tablecolumn abrechnungsbeginncolumn = new tablecolumn("abrechnungsbeginn"); abrechnungsbeginncolumn.setcellvaluefactory(new propertyvaluefactory<>("von")); tablecolumn abrechnungsendecolumn = new tablecolumn("abrechnungsende"); abrechnungsendecolumn.setcellvaluefactory(new propertyvaluefactory<>("bis")); tablecolumn rechnungsnummercolumn = new tablecolumn("rechnungsnummer"); rechnungsnummercolumn.setcellvaluefactory(new propertyvaluefactory<>("rechnungsnummer")); tablecolumn betragcolumn = new tablecolumn("betrag"); betragcolumn.setcellvaluefactory(new propertyvaluefactory<>("betrag")); tablecolumn kostenstellecolumn = new tablecolumn("kostenstelle"); kostenstellecolumn.setcellvaluefactory(new propertyvaluefactory<> ("kostenstelle")); tablecolumn telefonkostencolumn = new tablecolumn("telefon-kosten"); telefonkostencolumn.setcellvaluefactory(new propertyvaluefactory<>("telefon")); tablecolumn smskostencolumn = new tablecolumn("sms-kosten"); smskostencolumn.setcellvaluefactory(new propertyvaluefactory<>("sms")); tablecolumn internetkostencolumn = new tablecolumn("internet-kosten"); internetkostencolumn.setcellvaluefactory(new propertyvaluefactory<>("internet")); tablecolumn vertragsdetailscolumn = new tablecolumn("vertragsdetails"); vertragsdetailscolumn.setcellvaluefactory(new propertyvaluefactory<>("details")); vertragsdetailscolumn.setminwidth(100); table.getcolumns().addall( namecolumn, handynrcolumn, rechnungsdatumcolumn, abrechnungsbeginncolumn, abrechnungsendecolumn, rechnungsnummercolumn, betragcolumn, kostenstellecolumn, telefonkostencolumn, smskostencolumn, internetkostencolumn, vertragsdetailscolumn); } public static void settable(observablelist datensatz) { table.setitems(datensatz); }
so when change static methods/variables non-statics, works fine.
has idea try do? thank you!
your problem static variable not same table view see in ui - fxmlloader
can inject instance members, not static members. @ rate, it's not design have ui element static member, because can appear once in application scene graph anyway.
change tableview
member non-static member, don't initialize (the fxmlloader
inject actual control in ui assuming has proper fx:id
attribute). access controller see this question
Comments
Post a Comment