Hello could someone help me figure out how to make my menu item work? It calls createFrame() to add an additional inner frame. It runs but nothing is added to the JDesktopPane.
back in the create Frame() number of frames= 0
internal frame openFrameCount= 1
start obj() type= guide
createGuideInternalFrame
back in the create Frame() number of frames= 1
internal frame openFrameCount= 2
start obj() type= guide
back in the create Frame() number of frames= 2
internal frame openFrameCount= 3
start obj() type= guide
It looks like in my actionListener I am making a new JDesktopPane which calls createFrame();
I guess I am not sure how to have the actionListener call the createFrame(); without the importing the DeskTopPane class a dp so it knows what the createFrame() is "dp.createFrame();"
> It looks like in my actionListener I am making a new JDesktopPane which calls createFrame();
actually, you are creating another instance of 'DesktopPane' (a JFrame),
which calls createFrame()
>I guess I am not sure how to have the actionListener call the createFrame();
> without the importing the DeskTopPane class a dp so it knows what the createFrame() is "dp.createFrame();"
My JDesktop.class makes the JDesktop pane
a new internal frame class is called that creates and returned to it and adds it fine.
I used a setter to set the JDesktopPane into This new class
my actionPerformed calls the void method that of this new class and it tries the same thin only it tries to have the JDesktopPane that is now in the class
add the InternalFRame.
just looking at the code, you would need to call this
public void setJdp(JDesktopPane jdp) {
before calling this
CreateNewGuide() ---> jdp.add(frame);
otherwise jdp will be null
curious line this
public void CreateNewGuide() throws FileNotFoundException, IOException, PropertyVetoException {
why have the method name the same as the class name - most will think it should be a constructor, with errant 'void'm included
why all the unrelated throws exceptions
I changed the order of jdp creation
it still runs good from main but the
It does not want to deal with jdp.add(frame) in the createNewFrame()
JMenu item
you still haven't addressed the problem mentioned in my earlier post
in CreateNewGuide() you have this
public JDesktopPane jdp;
then, when you call cnf.CreateNewGuide(); (assuming [CreateNewFrame] cnf=new CreateNewGuide() is a typo)
includes
jdp.add(frame);
so, jdp has to be null
you can either use a constructor to pass a reference of the desktoppane to jdp, or
CreateNewFrame cnf=new CreateNewGuide();
cnf.setJdp(ref to desktoppane);//<----------------add this line
cnf.CreateNewGuide();
I can't see how a runnable class would help, you need to pass a reference of the
visible JFrame's desktoppane all the way down the line to where it is used in CreateNewGuide()
It might be worth you starting another project, just to simplify everything
only include the desktoppane and internal frame stuff, along with a single menuitem with actionListener.
if you still can't get it working, you'll have something small and complete to post here.
your code posted so far is very difficult to follow, things like
public class CreateNewGuide extends JInternalFrame
why would it extend JIternalFrame, when it uses an inner class that also extends JInternalFrame