Here's what I did:
- Created a new Project / Java / Java Application, changed the default project name, and UNCHECKED the "Create Main Class" checkbox.
- Right-clicked on the default package under the Source Packages and changed its name.
- Right-clicked on the newly named package and added to it a New JPanel Form. NetBeans created a class file that extends JPanel and tells Java how to customize a panel for my UI.
- Added a button, text field, and label for a very rudimentary UI. I changed their names with a right-click in the Inspector at the left: one of the choices on the menu is Change Variable Name.
- Added a few variables at the top of the class definition.
- Added import statements each time that the NetBeans UI asked me to.
- Right-clicked both the panel and the button to add mouse event handlers.
- Added main( ) and paintComponent( ) methods to the source.
Having tried many variations with JFrame and JPanel, I decided to just to draw a fake pane that you won't see until the program runs. I have some ideas about more elegant ways to draw on a panel/frame combination, but hey — I needed to get this baby done!
No comments:
Post a Comment