• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

my java project.  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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



 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

Winston
 
Marshal
Posts: 59756
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again
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.
 
Campbell Ritchie
Marshal
Posts: 59756
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!