Using NetBeans IDE
-
I have a class JPanel that I want to add other JPanels onto during run-time. I can add a JPanel using the NetBeans IDE for "design", but the IDE will not let me dynamically add a new JPanel and let me position it on the main JPanel . When I look at the documentation, it appears that there are inherited methods that would allow this type of operation, such as setLocation(int, int). The IDE complains about this method, and the list of available methods that appears when editing the code, has a very limited set. Is there a way around this using the IDE? Thanks for your time.
AF Pilot
-
I have a class JPanel that I want to add other JPanels onto during run-time. I can add a JPanel using the NetBeans IDE for "design", but the IDE will not let me dynamically add a new JPanel and let me position it on the main JPanel . When I look at the documentation, it appears that there are inherited methods that would allow this type of operation, such as setLocation(int, int). The IDE complains about this method, and the list of available methods that appears when editing the code, has a very limited set. Is there a way around this using the IDE? Thanks for your time.
AF Pilot
Reagan Conservative wrote:
I have a class JPanel
I would rename your class to something more appropriate if I were you. If you have a look at the code Netbeans generates with the designer, then you will see something which looks like this.
JPanel jp = new JPanel();
//Set jp properties
[InsertParentControlHere].add(jp);
Add that in the code where you need it.
My failometer has shot off the end of the scale! I seem to have misplaced my ban button.. no wait... found it!
-
Reagan Conservative wrote:
I have a class JPanel
I would rename your class to something more appropriate if I were you. If you have a look at the code Netbeans generates with the designer, then you will see something which looks like this.
JPanel jp = new JPanel();
//Set jp properties
[InsertParentControlHere].add(jp);
Add that in the code where you need it.
My failometer has shot off the end of the scale! I seem to have misplaced my ban button.. no wait... found it!
I was just using this as a generic example. The actual name is not JPanel. I was going to try and use this "JPanel" to draw graphics on and place it on another "JPanel". I think that the better approach is just to draw directly to the "JPanel" without adding a whole bunch of smaller "JPanel"s. Thanks for replying.
AF Pilot
-
I was just using this as a generic example. The actual name is not JPanel. I was going to try and use this "JPanel" to draw graphics on and place it on another "JPanel". I think that the better approach is just to draw directly to the "JPanel" without adding a whole bunch of smaller "JPanel"s. Thanks for replying.
AF Pilot
Apologies, I misunderstood.
Reagan Conservative wrote:
I think that the better approach is just to draw directly to the "JPanel" without adding a whole bunch of smaller "JPanel"s.
Agreed, I see what you mean about inheritence now. Overriding the paintComponant method should do the trick. Have a look at this[^], it may help.
My failometer has shot off the end of the scale! I seem to have misplaced my ban button.. no wait... found it!