Is there a possible way to override the paintComponent() method in the auto-generated GUI code in NetBeans? I managed to manually draw a graph without using the drag-and-drop components, and I need to make adjustments (e.g. adding radio button group) which I find really time consuming and tedious work. I created a GUI u开发者_Python百科sing the NetBean's drag-and-drop components, but I cannot edit them. Is it possible?
Pls give me a solution. Greatly apprecite any insight Many thanks in advance
You can override the code used to create a component that you drag-and-drop onto a form in the NetBeans Swing UI 'builder'.
You can do the following:
- Select a component from the palette.
- Place the component.
- right click on the component and select the 'Customize code' item.
- Edit the code in the dialog that is displayed.
alt text http://www.freeimagehosting.net/uploads/4c75ea4390.png
There is another way to customize the code, that is a bit more complex, that you may find useful.
When you drag-and-drop a component that you wish to customize, look at the Properties panel on the right-hand side of the layout editor. You can customize code by altering the Code properties, like "Custom Creation Code".
alt text http://www.freeimagehosting.net/uploads/4809b0fd4f.png
There is more info about this method in this answer: How to modify/add code to the initComponents() method in Java using NetBeans?
精彩评论