Note that there are some explanatory texts on larger screens.

plurals
  1. POMove application to other frame and then back to previous
    primarykey
    data
    text
    <p>I'm writing java applet. I want to to open a new Frame with content actually stored in my Applet. I'm opening new Frame through the Button:</p> <pre><code>openInNew.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { createDialog(); } }); //this Function retrieves Frame for applet public Frame getParentFrame( Component child ) { Container c = child.getParent(); while ( c != null ) { if ( c instanceof Frame ) { return ( Frame ) c; } c = c.getParent(); } return null; } private void createDialog() { Frame f=getParentFrame(openInNew); //openInNew is a button to Open a JDialog frame = new AppletFrame("NEW FRAME",jContentPane); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } </code></pre> <p>Here is the constructor for <code>AppletFrame</code>:</p> <pre><code>public AppletFrame(String string, JPanel jContentPane, Frame f) { super(f,string); this.setContentPane(jContentPane); this.setSize(790, 650); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { removeAll(); FileListViewer.destroyFrame(); } }); } public static void destroyFrame() { jContentPane= (JPanel) frame.getContentPane(); jContentPane.repaint(); /*this one should repaint the Applet View, but the result * is still the same. jContentPane is not null, * it is filled with acutal components. */ jContentPane.setVisible(true); frame.dispose(); frame.setVisible(false); frame=null; } </code></pre> <p>My problem is that <code>jConentPane</code> is a reference, so immediately when I open my <code>AppletFrame</code> object, there is nothing stored in my basic Applet Frame. I wanted to set again <code>jContentPane</code> to <code>FileListViewer</code>, but I can't refer to non-static method in static <code>destroyFrame()</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload