Re: JFrame from JPanel



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.
.



Relevant Pages

  • Re: JFrame from JPanel
    ... public class P1 extends JPanel implements ActionListener { ... On a different file, but in the same dir, I have a JFrame: ... I assumed petoeter had some good reason for wanting to "start the JFrame" from within the JPanel's ActionListener. ...
    (comp.lang.java.gui)
  • Re: JFrame from JPanel
    ... I created a JPanel: ... public class P1 extends JPanel implements ActionListener { ... On a different file, but in the same dir, I have a JFrame: ... JFrame ditframe = new JFrame { ...
    (comp.lang.java.gui)
  • Re: How to clear or reset or close and reopen a textfield
    ... I have a question regarding my little app below. ... My question is in the IF/ELSE block of the textlistener class. ... public class InputListener extends JFrame ... public class Clisten implements TextListener ...
    (comp.lang.java.gui)
  • setBackground in JFrame
    ... Killer Ap version 0.00002 seems to be avoiding the setBackground method ... I have a class that extends JFrame, I use the class in an application ... revealed screen area until I release the ... public class BasicFrame extends JFrame ...
    (comp.lang.java.help)
  • Re: starting with graphics (grr)
    ... > a class for the LEDs and a panel that extends a JFrame. ... > public class LEDPanel extends JFrame { ...
    (comp.lang.java.help)