3

通过单击“Add Int Frame”按钮,我在 tabbedPane 上绘制 JInternalFrame,在这个水平分割的 JSplitPane 的右侧。

在此处输入图像描述

在这个 InternalFrame 上,我可以通过单击“添加拆分窗格”按钮来添加嵌套的 JSplitPane。

嵌套的 JSplitPanes 仅在我移动 InternalFrame 时出现:如何在按下按钮时立即显示 JSplitPanes?

这是我的代码

public class MultiSplit extends javax.swing.JFrame {

JInternalFrame jif;
JSplitPane jsp1,jsp2,jsp3,jsp4,jsp5, jsp6;
JTextArea textArea1, textArea2, textArea3, textArea4, textArea5, textArea6;
int click = 0;

public MultiSplit() {
    initComponents();
    setLocationRelativeTo(null);
}

private void AddIntFramesMousePressed(java.awt.event.MouseEvent evt) {                                      
    click = 0;        
    jif = new JInternalFrame();
    jPanel1.add(jif);
    jif.setSize(750, 600);
    jif.setResizable(true);
    jif.setClosable(true);
    jif.setMaximizable(true);
    jif.setIconifiable(true);
    jif.setVisible(true);
}                   

private void AddPanesButtonMousePressed(java.awt.event.MouseEvent evt) {                                            
    click++;      
    if(click ==1){
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    jsp1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, textArea1, textArea2);
    jsp1.setVisible(true);       
    jsp1.setResizeWeight(0.75);
    jsp1.setDividerSize(2);
    jif.add(jsp1);
    }        
    else if(click==2){
      textArea3 = new JTextArea();  
      jsp2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jsp1, textArea3);
      jsp2.setVisible(true);
      jsp2.setResizeWeight(0.80);
      jsp2.setDividerSize(2);
      jif.add(jsp2);
    }        
    else if(click==3){
      textArea4 = new JTextArea();  
      jsp3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jsp2, textArea4);
      jsp3.setVisible(true);
      jsp3.setResizeWeight(0.85);
      jsp3.setDividerSize(2);
      jif.add(jsp3);
    }
   }
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            new MultiSplit().setVisible(true);
        }
    });
  }
}

绘制的 JSplitPanes

4

1 回答 1

3

如何使用内部框架:“通常,您将内部框架添加到桌面窗格。” 无论您JInternalFrame是否在 a 上JDesktopPane,您仍然需要pack()内部框架,就像封闭的Window.

于 2012-05-10T09:50:34.340 回答