Re: JFrame from JPanel
- From: RedGrittyBrick <RedGrittyBrick@xxxxxxxxxxxxx>
- Date: Thu, 22 Mar 2007 19:43:52 +0000
Brandon McCombs wrote:
RedGrittyBrick wrote:petoeter wrote: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?
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
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.
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.
.
- References:
- JFrame from JPanel
- From: petoeter
- Re: JFrame from JPanel
- From: RedGrittyBrick
- Re: JFrame from JPanel
- From: Brandon McCombs
- JFrame from JPanel
- Prev by Date: Re: Requesting tips, comments for an EDT thread-safe game architecture
- Next by Date: ResultSet and getArray() - Error on AWT
- Previous by thread: Re: JFrame from JPanel
- Next by thread: How to print a JTextArea?
- Index(es):
Relevant Pages
|