creating num of iframes

trouble creating a new internal frame

Page 1 of 1

1 Replies - 1683 Views - Last Post: 27 January 2006 - 03:22 PM Rate Topic: -----

#1 cloud2181  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 11-February 05

creating num of iframes

Posted 27 January 2006 - 01:06 AM

ok so i'm trying to Use a JDesktopPane. i can have it load one InternalFrame atm. i'm trying to have it so that if you can one or more Internal Frames. so far the project is compling correctly but it's sending an error when i hit the button here is the code i'm using.
//intialize panes and frames in class def
public JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable);
      public JInternalFrame iframe2 = new JInternalFrame(title, resizable,            closeable, maximizable, iconifiable);
     public JDesktopPane desktop = new JDesktopPane();
     public JFrame frame = new JFrame();
public JButton add = new JButton("add iframe");
 


private class ButtonListener implements ActionListener
  {
 	 public void actionPerformed(ActionEvent evt)
 	 {
    if (evt.getSource() == add)
    {
   	 
   	 desktop.add(iframe2);
   	 iframe2.setSize(200,50);
   	 iframe.setVisible(true);
   	 frame.getContentPane().add(desktop);
    
    }
 	 }
  }


any clue as to what is happening?

Is This A Good Question/Topic? 0
  • +

Replies To: creating num of iframes

#2 cloud2181  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 11-February 05

Re: creating num of iframes

Posted 27 January 2006 - 03:22 PM

ok figured it out now i've made an array of frames that adds one each time it's clicked.

but now i'm having a problem in that it adds to frames each time i click the button. it's also not recogizing any changes i've made such as to the title.
here is the code again improved:
 //actionlistener for add button that makes new frames
    add.addActionListener(new ActionListener()
    {
   	 public void actionPerformed(ActionEvent evt)
   	 {
      if (evt.getSource()==add)
      {
     	 
      
   	 iframe[x] = new JInternalFrame("new frame"  ,true,true,true,true);
   	 System.out.println(x);
   	 iframe[x].setVisible(true);
   	 iframe[x].setSize(500,20);
   	 iframe[x].getContentPane().add(new JButton(name));
     	 desktop.add(iframe[x]);
     	 x++;	
      }
   	 }
    }
);



any ideas i would love to hear them
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1