• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems creating a new frame

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are few lines from one of my programs:

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?
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic