通过单击“添加Int框架”按钮,我在tabbedPane上绘制JInternalFrame,在此HORIZONTAL分割的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);
}
});
}
}
答案 0 :(得分:3)
How to Use Internal Frames:“通常,您将内部框架添加到桌面窗格。”无论您的JInternalFrame
是否在JDesktopPane
上,您仍然需要pack()
内部框架,就像封闭的Window
一样。