![]() |
| ||
| Switching between Multiple Frames The following four classes are an attempt to set up three different JFrames and switch between them. The three frames are: MainView, DetailView, and FormView. The main class is MultipleFramesExample. The four source codes constitute a NetBeans project with a package called FrameViews. MainView, DetailView, and FormView are essentially identical source codes, each containing a JButton. When a button in one of the views is clicked, you are to be taken to another view. When I try to Run the project, the last line of each source code creates a compile error, "Cannot find variable". Can anyone tell me how to correct the following four source codes? package FrameViews; _______________________________________ package FrameViews;__________________________________________ package FrameViews;____________________________________________ package FrameViews;_______________________________________ Thank you, J.D. Seader |
| ||
| Re: Switching between Multiple Frames mV.createMainView(); mV has not been declared in this class. dV.createDetailView(); dV has not been declared in this class. etc etc. You should make a new instance for the variables you want to use, or let them get returned from other classes (if you don't want a new one). So in the first class this would be: MainView MV = new MainView(); This should solve the problem I think. Please say so if I am wrong. Greetings, jens |
| ||
| Re: Switching between Multiple Frames Quote:
Jens, Thank you for your help. I followed your suggestion and added a declaration to each class directly after the class declaration. The program now compiles without any errors, but when I run it, no frames with buttons appear. I must have another problem. Can you help me? J.D. Seader |
| ||
| Re: Switching between Multiple Frames Jens, With a slight change, my project now works beautifully. Thank you very much for your help. I thought the package statement would eliminate the need for the declarations you suggested, but it didn't. J.D. Seader |
| ||
| Re: Switching between Multiple Frames how would you do this in Netbean IDE? can you show the examples? let say: the first screen appear, and it has a series of button. each button goes to specific JFrame... but i have no clues until now. |
| All times are GMT -4. The time now is 8:52 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC