这涉及到程序架构问题,我也不想随便说了,因为也不是三言二语能解决的,
简单提一下,使用JInternalFrame.
再说一句,这不是jbuilder的功能,jbuilder也没提供这种功能。这种程序架构问题只能自己解决了。
如果你实在要具体实现,可以和我email联系。[email protected]

解决方案 »

  1.   

    You have to use JDesktopPane as your parent window and accommondate JInternalFrame as your child window. The basic steps are1. create JDesktopPane object in a class that inherited from JFrame
    .
    2. create JInternalFrame object in the same class and add add whatever components that you feel you need to.3. add the JInternalframe object to the object of JDesktopPane 
      

  2.   

    我就要下了,我这和有例子代码,很简单
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    import java.io.*;
    import java.lang.*;
    import javax.swing.undo.*;public class LookAndFeel{
    public static void main(String[] args){
    JFrame F=new MainFrame();
    F.setVisible(true);
    }//end main
    }//end lookandfeel classclass MainFrame extends JFrame{
    JDesktopPane desktop;
    JFrame topFrame;
    JMenuBar jMenuBar;
    JPopupMenu jpMenu;
    JToolBar toolBar;
    Dimension scrDimension;

    public MainFrame(){
    super("应用程序主窗口");
    Toolkit TK=this.getToolkit();
    scrDimension=TK.getScreenSize();
    setBounds(0,0,scrDimension.width,scrDimension.height);
    buildContent();
    buildMenu();
    buildToolBar();

    this.getContentPane().add(toolBar,BorderLayout.NORTH);
    this.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    quit();
    }
    });
    }// end of MainFrame()

    protected void buildContent(){
    desktop=new JDesktopPane();
    getContentPane().add(desktop);
    }//end of buildContent()

    protected void buildMenu(){
    jMenuBar=new JMenuBar();
    jMenuBar.setOpaque(true);//把菜单栏的不透明属性设为true,使得JMenuBar的显示能自动重绘
    JMenu mfile= buildFileMenu();
    mfile.setMnemonic('F');
    jMenuBar.add(mfile);
    setJMenuBar(jMenuBar);
    }// end of buildMenu()

    public void quit(){
    System.exit(0);
    }

    protected void buildToolBar(){
    toolBar=new JToolBar();
    toolBar.setFloatable(true);

    ToolBarAction tba_new=new ToolBarAction("新建",new ImageIcon("icon/new.jpg"));
    ToolBarAction tba_save =new ToolBarAction("保存",new ImageIcon("icon/save.jpg"));
    ToolBarAction tba_open=new ToolBarAction("打开",new ImageIcon("icon/open.jpg"));
    ToolBarAction tba_close =new ToolBarAction("关闭",new ImageIcon("icon/close.jpg"));

    JButton JB;
    JB=toolBar.add(tba_new);
    JB.setActionCommand("TB_NEW");
    JB.setToolTipText((String)tba_new.getValue(Action.NAME));

    JB=toolBar.add(tba_open);
    JB.setActionCommand("TB_OPEN");
    JB.setToolTipText((String)tba_open.getValue(Action.NAME));

    JB=toolBar.add(tba_close);
    JB.setActionCommand("TB_CLOSE");
    JB.setToolTipText((String)tba_close.getValue(Action.NAME));

    toolBar.addSeparator();
    JB=toolBar.add(tba_save);
    JB.setActionCommand("TB_SAVE");
    JB.setToolTipText((String)tba_save.getValue(Action.NAME));
    tba_save.setEnabled(false);
    }//end of buildToolBar()

    public JMenu buildFileMenu(){
    JMenu mFile=new JMenu("文件(F)");
    JMenuItem miNew=new JMenuItem("新建(N)");
    JMenuItem miOpen=new JMenuItem("打开(O)");
    JMenuItem miClose=new JMenuItem("关闭(C)");
    JMenuItem miQuit=new JMenuItem("退出(X)");

    miClose.setEnabled(false);
    miNew.setMnemonic('N');
    miOpen.setMnemonic('O');
    miClose.setMnemonic('C');
    miQuit.setMnemonic('X');

    mFile.add(miNew);
    mFile.add(miOpen);
    mFile.add(miClose);
    mFile.addSeparator();
    mFile.add(miQuit);

    miNew.setAccelerator(KeyStroke.getKeyStroke('N',java.awt.Event.CTRL_MASK,false));
    miOpen.setAccelerator(KeyStroke.getKeyStroke('O',java.awt.Event.CTRL_MASK,false));
    miClose.setAccelerator(KeyStroke.getKeyStroke('C',java.awt.Event.CTRL_MASK,false));
    miQuit.setAccelerator(KeyStroke.getKeyStroke('X',java.awt.Event.CTRL_MASK,false));

    miNew.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    makeNewFrame();
    }
    });
    miOpen.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    openDocument();
    }
    });
    miQuit.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    quit();
    }
    });
    return mFile;
    }//end of buildFileMenu()
    public void makeNewFrame(){
    JInternalFrame ifNew=new NewFrame();
    desktop.add(ifNew,new Integer(1));
    try{
    ifNew.setVisible(true);
    ifNew.setSelected(true);
    }catch(java.beans.PropertyVetoException e2){}
    }//end of makeNewFrame
    public void openDocument(){
    JFileChooser fileChooser=new JFileChooser();
    fileChooser.showOpenDialog(this);
    }//end of openFrame()
    }//end of class MainFrameclass NewFrame extends JInternalFrame{
    static int Count=0;
    static final int offset=30;

    public NewFrame(){
    super("",true,true,true,true);//五个参数依次是:标题,是否可改变大小、是否可关闭、是否最大化和最小化
    setTitle("Untitled Document "+(Count++));

    JPanel jpTop=new JPanel();
    jpTop.setBorder(new EmptyBorder(10,10,10,10));
    jpTop.setLayout(new BorderLayout());

    JTextArea jtaContent=new JTextArea(10,30);
    jtaContent.setBorder(new EmptyBorder(0,5,0,5));
    jtaContent.setLineWrap(false);//是否自动换行

    JScrollPane textScroller=new JScrollPane(jtaContent,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    jpTop.add(textScroller,BorderLayout.CENTER);

    setContentPane(jpTop);
    pack();
    setLocation(offset * Count,offset*Count);
    }//end of NewFrame()
    }//end of NewFrame classclass ToolBarAction extends AbstractAction{  public ToolBarAction(String name,Icon icon){
        super(name,icon);
      }  public void actionPerformed(ActionEvent e){
        try{
          System.out.println("cmd: "+e.getActionCommand());
        }catch(Exception ex){}
      }
    }//end of ToolBarAction class