at the moment im learning java and i have created 2 .classes
can someone help me by editing it so that the second class is activated by the menubar in the first class. im really lost on multi class java. tutorials dont seem to help
jeff howard wrote:can someone help me by editing it so that the second class is activated by the menubar in the first class. im really lost on multi class java. tutorials dont seem to help
First: Welcome to JavaRanch.
Second: I hate to say, but nobody's going to go through a thousand lines of code.
I suggest you read the SSCCE page (←click) and come up with something more focused and reasonable.
Also, please DontWriteLongLines; it makes your thread very hard to read.
For future reference, the rule is:
80 characters max.
(the SSCCE page actually recommends 62)
And that includes string literals AND comments AND long method calls.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Agree with Winston that the long lines make your code hard to understand.
The long list of menu items without spaces is particularly difficult to read. Why have you got such a long declaration? Why are they fields rather than local variables in the constructor/setUpGUI method?
Why are you hard‑coding so much text? Why don't you load the text from a resources file?
Why have you got \n in the text? I know the books all show \n but (unless somebody has told you they want an LF character) it may be the wrong line end.
I would go farther than Winston's suggestion of an SSCCE. You are not activating any classes; you probably want to create an instance and display it. Why have you got so many top‑level containers (frames)? You should be aiming for one frame full stop. Get yourself a completely new app. I would suggest you start by displaying a frame with one component added. Remember always to start the event despatch thread.That code is probably full of spelling errors, so you will have to beat it into submission before it will actually compile.
Now add a menu to the frame. Now add a menu item to the frame. Now add an ActionListener (as an anonymous class) to the menu item which changes the colour of the panel. Now you can work out how to use that listener to make something else appear. You may want a desktop pane and internal frames rather than multiple frames. If you need a second top‑level container, use a dialogue.