This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a help menu bar and it has about section and when that is called I want to open another frame and have my name and a logo of sorts. I am having hard time even having it open the frame window once about is selected. Below I have commented out thinking I am on the right track. I am not sure I keep looking at suns java.awt packet and I can't find anything that will help. Any ideas would greatly appreciated
You can see for Help I open a new frame, which happens to display an HTML help file. For HelpAbout I just show an option pane with hard coded contents. Do either of those help? It looks like you're trying to create the HelpAbout window invisible and just show and hide it. That might be more trouble than it's worth ... would it be ok to create it on demand and let it be destroyed on close?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Feb 11, 2003
I got it to show a frame now but when I click on about under the menu it shows a frame but I will no draw an oval or anything from the Graphics package. I added about section under the action listner class listed on large secion of code above. But once with about window runs you can see in blow up in the command promp.
but I will no draw an oval or anything from the Graphics package.
The way to draw on a component in Java is to subclass the component and override the paintComponent(Graphics) method. Then Java will call this method when the window needs to be painted. If you try to do it the way you're doing it, then as soon as the window is resized, moved, overlapped, etc, the picture will disappear and never come back. What you need to do is: 1) Make a subclass of JPanel. 2) Override the paintComponent() method. Do the drawing in that method. 3) When you create a JFrame in response to your menu pick, also create am instance of your JPanel subclass and add it to the JFrame's contentPane -- i.e., myFrame.getContentPane().add(new MyJPanel()) . That'll do it!