robben
2008-11-13 20:26:13 UTC
Hi,
I have a simple question, Iâm currently developing a GUI app using Java. It mainly consists of a main form (JFrame) a couple of texboxes and three JPanelâs which I add graphics to.
I have created the GUI form using the Netbeans IDE including the JPanelâs. What I would like to do is when I add something to each of the JPanels I would like to call repaint() and then for it to call the paintComponent() method which I override and then in this method I add the image I have created onto the JPanel. I do this for all three JPanels.
At the moment I have four classes. The first class lets call it MainForm is the class generated by NetBeans for the GUI objects. The three further classes are for each one of the JPanels. In these classes I have a overridden the paintComponent() which is called when I call repaint from a separate function in the class.
The problem I have is that the paintComponent() method is never called for any of the three JPanels. Lets say that one of the JPanels is called myJPanel which is in my MainForm class generated by NetBeans.
I have a myJPanel class which has a function which creates the graphic and then calls repaint and which then should call paintComponent(). But it does not work, would anyone know how I can get this working?
Thanks in advance for your help. :)
I have a simple question, Iâm currently developing a GUI app using Java. It mainly consists of a main form (JFrame) a couple of texboxes and three JPanelâs which I add graphics to.
I have created the GUI form using the Netbeans IDE including the JPanelâs. What I would like to do is when I add something to each of the JPanels I would like to call repaint() and then for it to call the paintComponent() method which I override and then in this method I add the image I have created onto the JPanel. I do this for all three JPanels.
At the moment I have four classes. The first class lets call it MainForm is the class generated by NetBeans for the GUI objects. The three further classes are for each one of the JPanels. In these classes I have a overridden the paintComponent() which is called when I call repaint from a separate function in the class.
The problem I have is that the paintComponent() method is never called for any of the three JPanels. Lets say that one of the JPanels is called myJPanel which is in my MainForm class generated by NetBeans.
I have a myJPanel class which has a function which creates the graphic and then calls repaint and which then should call paintComponent(). But it does not work, would anyone know how I can get this working?
Thanks in advance for your help. :)