By clicking the "Add Int Frame" button I plot JInternalFrame on a tabbedPane, in the right part of this HORIZONTAL divided JSplitPane.
On this InternalFrame I can add nested JSplitPane by clicking the "Add Split Pane" button.
Nested JSplitPanes appears only if I move the InternalFrame: how to show JSplitPanes immediately visible when button is pressed?
Here is my code
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);
}
});
}
}
How to Use Internal Frames: "Usually, you add internal frames to a desktop pane." Whether your JInternalFrame
is on a JDesktopPane
or not, you still need to pack()
the internal frame just like the enclosing Window
.