new 一个JInternalFrame,然后放到JFrame里,到它最大化后也是在浮动条的下面,怎么使JInternalFrame的头与浮动条处于同一行上(即最大化,最小化按钮与浮动条处于用一行上)?请高手帮帮忙了,谢谢!

解决方案 »

  1.   

    "Usually, you add internal frames to a desktop pane. The desktop pane, in turn, might be used as the content pane of a JFrame. The desktop pane is an instance of JDesktopPane."It means that you should add JInternalFrame to a JDesktopPane not to a JFrame.
      

  2.   

    应该把JInternalFrame 放到JDesktopPane 上,同意楼上。
      

  3.   

    你的意思是不是把JInternalFrame加到JDesktopPane上,我也就是把它加到上面的哦。
    但是怎么使JInternalFrame最大化后最大,最小按妞与菜单栏同一高度呢?
      

  4.   

    InternalFrame最大后它仍在DesktopPane上,所以它不可能与MenuBar同一高度,我是这么认为,
    没经过验证。
      

  5.   

    package intf;import java.awt.event.*;
    import java.awt.*;
    import com.borland.jbcl.layout.*;
    import javax.swing.*;
    import java.beans.*;/* Used by InternalFrameDemo.java. */
    public class MyInternalFrame
        extends JInternalFrame {
      static int openFrameCount = 0;
      static final int xOffset = 30, yOffset = 30;  public MyInternalFrame() {
        super("Document #" + (++openFrameCount),
              true, //resizable
              true, //closable
              true, //maximizable
              true); //iconifiable    //...Create the GUI and put it in the window...    //...Then set the window size or call pack...
        setSize(300, 300);    //Set the window's location.
        setLocation(xOffset * openFrameCount, yOffset * openFrameCount);
        try {
          jbInit();
        }
        catch (Exception e) {
          e.printStackTrace();
        }
      }  private void jbInit() throws Exception {
        jButton1.setText("单击此处新增子窗口");
        jButton1.addActionListener(new MyInternalFrame_jButton1_actionAdapter(this));
        this.getContentPane().setLayout(xYLayout1);
        this.getContentPane().add(jButton1, new XYConstraints(107, 96, -1, -1));
      }  XYLayout xYLayout1 = new XYLayout();
      JButton jButton1 = new JButton();  void jButton1_actionPerformed(ActionEvent e) {
        System.out.println("adfas");
        MyInternalFrame a = new MyInternalFrame();
        this.getParent().add(a);
        a.setVisible(true);
        try {
          a.setSelected(true);
        }
        catch (PropertyVetoException ex) {
        }
        //  JOptionPane.showMessageDialog(null,"dfd");  }
    }class MyInternalFrame_jButton1_actionAdapter
        implements java.awt.event.ActionListener {
      MyInternalFrame adaptee;  MyInternalFrame_jButton1_actionAdapter(MyInternalFrame adaptee) {
        this.adaptee = adaptee;
      }  public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
      }
    }