Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2007

Tip: Looking for answers? Try searching our database.

JFrame from JPanel

Thread view: 
petoeter - 20 Mar 2007 17:40 GMT
This is e real newbie problem.
I created a JPanel :

public class P1 extends JPanel implements ActionListener {
                           some code
                          }

On a different file, but in the same dir,  I have a JFrame:

public class F1 {
     JFrame ditframe = new JFrame {
                         some code
                        }

I try to start the JFrame from the JPanel somewhere under:

      public void actionPerformed(Action Event e) {
                               .....
                        }

How d I call the JFrame?

Thanks,
RedGrittyBrick - 20 Mar 2007 21:13 GMT
> This is e real newbie problem.
> I created a JPanel :
[quoted text clipped - 17 lines]
>
> How d I call the JFrame?

Probably by making ditframe an instance variable, providing a method in
F1 that does "ditframe.setVisible(true);", then calling that method from
 P1 after instantiating F1.

If that doesn't make any sense to you then read this
http://mindprod.com/jgloss/sscce.html
Brandon McCombs - 22 Mar 2007 04:28 GMT
>> This is e real newbie problem.
>> I created a JPanel :
[quoted text clipped - 24 lines]
> If that doesn't make any sense to you then read this
> http://mindprod.com/jgloss/sscce.html

Or if he extended JFrame with F1 like he extended JPanel with P1 then he
wouldn't have to have a separate method to make F1 visible and he
wouldn't need to create his own JFrame within F1 either.
RedGrittyBrick - 22 Mar 2007 20:43 GMT
>>> This is e real newbie problem.
>>> I created a JPanel :
[quoted text clipped - 28 lines]
> wouldn't have to have a separate method to make F1 visible and he
> wouldn't need to create his own JFrame within F1 either.

That would make more sense. I assumed petoeter had some good reason for
wanting to "start the JFrame" from within the JPanel's ActionListener.
In retrospect that seems unlikely.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.