voila, j'ai une application qui a :
un login qui ouvre un borderpane au centre duquel je switch des anchorpanes. tout fonctione
sauf lorsque je veux charger un tableview. j'ai des erreurs que je copie ici. il y a
une ligne qui génére ces erreurs et lorsque je la mets en commentaire, il n'y a pas d'erreur,
mais il ne se passe rien aussi. cette ligne est entre guillemet dans "editController".
quelqu'un peut avoir une idée ??
voici la partie du code qui génère ces erreurs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class editController implements Initializable{ @ FXML private BorderPane bp; @FXML private AnchorPane ap1; @FXML private Pane ape2; @FXML private Label lbl1; @FXML private ComboBox<String> combo; @FXML private Label lbl2; @FXML private TextField txt0; @FXML private Button btnshow; @FXML private Pane panecenter; @FXML private tbviewController tbvc; @FXML private loginController mc; public void setMain(loginController mc) { this.mc = mc; } public ObservableList<String> list = FXCollections.observableArrayList("aa","bb","cc","dd","ee","ff"); public ArrayList<String> data = new ArrayList<String>(2); @Override public void initialize(URL location, ResourceBundle resources) { // TODO Auto-generated method stub combo.setItems(list); } public void btn_show() { try { tbviewController tbvc = new tbviewController(data); FXMLLoader loader = new FXMLLoader(getClass().getResource("/pkgfxml/tabview.fxml")); loader.setController(tbvc ); data.add(combochanged().trim()); data.add(txt0.getText().trim()); AnchorPane ap1_tbv = (AnchorPane) loader.load(); loader.getController(); tbvc .setMain(mc); " mc.getBorderPane().setCenter(ap1_tbv); " } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } public BorderPane getBorderPane() { // TODO Auto-generated method stub return bp; } public String combochanged() { return combo_op.getValue(); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 public class tbviewController implements Initializable{ PreparedStatement prepareStatement1 = null; ResultSet rst1 = null; Connection conn = null; String query1 = null; String myvar0 = ""; String myvar1 = ""; @FXML private AnchorPane ap1_tbv; @FXML private TableView<OPerDetails> tb1; @FXML private TableColumn<OPerDetails, String> col_11; @FXML private TableColumn<OPerDetails, String> col_22; @FXML private TableColumn<OPerDetails, String> col_33; @FXML private TableColumn<OPerDetails, String> col_44; @FXML private TableColumn<OPerDetails, String> col_55; @FXML private TableColumn<OPerDetails, String> col_66; @FXML private loginController mc; @FXML private ComboBox<String> combo; public void setMain(loginController mc) { this.mc = mc; } public ObservableList<OPerDetails> list0 = FXCollections.observableArrayList(); public ArrayList<String> data = new ArrayList<String>(2); public tbviewController(ArrayList<String> data) { this.data = data; } @Override public void initialize(URL url, ResourceBundle rb) { tbviewController tbvc = new tbviewController(data); myvar0 = etbc.data.get(0); myvar1 = etbc.data.get(1); try { Class.forName("com.mysql.cj.jdbc.Driver"); String url1 = "jdbc:mysql://localhost:3306/db1"; String username = "root"; String password = ""; Connection conn = DriverManager.getConnection(url1,username,password); query1 = String.format("SELECT table_db1.var1,table_db1.var2,table_db1.var3,table_db1.var4,table_db1.var5,table_db1.var6 from table_db1 where left(table_db1.var6,6)='%s' and table_db1.var1='%s'",myvar1,myvar0); prepareStatement1 = conn.prepareStatement(query1); rst1 = prepareStatement1.executeQuery(); while(rst1.next()) { list0.add(new OPerDetails(rst1.getString(1),rst1.getString(2),rst1.getString(3),rst1.getString(4),rst1.getString(5),rst1.getString(6))); } col_11.setCellValueFactory(new PropertyValueFactory<OPerDetails,String>("11")); col_22.setCellValueFactory(new PropertyValueFactory<OPerDetails,String>("22")); col_33.setCellValueFactory(new PropertyValueFactory<OPerDetails,String>("33")); col_44.setCellValueFactory(new PropertyValueFactory<OPerDetails,String>("44")); col_55.setCellValueFactory(new PropertyValueFactory<OPerDetails,String>("55")); col_66.setCellValueFactory(new PropertyValueFactory<OPerDetails,String>("66")); tb1.setItems(list0); conn.close(); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } }java.lang.NullPointerException
at app1.editer_tarif_arrController.btn_show(editController.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8411)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748)
Partager