kelahcim
2004-03-01 13:07:08 UTC
Hi,
I have a problem with JInternalFrame, recently.
I would like to create such a JInternalFrame, that wouldn't be able to move.
At the end there is a small program which demonstrates what am I thinking
about.
You can see that there are three "panels"
1. JDesktopPane
2. JPanel
3. JTabbedPane
You can also see, that only panel able to stop JInternalFrame from moving is
JTabbedPane.
Can anybody tell me if this is a some kind of a parameter (which determines
whether Frame is able to move or not) or maybe I have to work harder to
obtain such an efect?
Best regards,
Michal
/**
* code
*/
import java.awt.Dimension;
import javax.swing.DefaultDesktopManager;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;
public class Example extends javax.swing.JFrame {
public Example() {
initComponents();
JInternalFrame jif1 = new JInternalFrame("hello 1");
jif1.setVisible(true);
jTabbedPane1.add(jif1);
JInternalFrame jif2 = new JInternalFrame("hello 2");
jif2.setVisible(true);
jif2.setBounds(0,0, 200,100);
jDesktopPane1.add(jif2);
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jSplitPane1 = new javax.swing.JSplitPane();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jSplitPane2 = new javax.swing.JSplitPane();
jDesktopPane1 = new javax.swing.JDesktopPane();
jPanel2 = new javax.swing.JPanel();
jInternalFrame1 = new javax.swing.JInternalFrame();
getContentPane().setLayout(new java.awt.GridLayout(1, 1));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
jSplitPane1.setLeftComponent(jTabbedPane1);
jPanel1.setLayout(new java.awt.GridLayout(1, 1));
jSplitPane2.setLeftComponent(jDesktopPane1);
jPanel2.setLayout(new java.awt.GridBagLayout());
jInternalFrame1.setTitle("hello 3");
jInternalFrame1.setVisible(true);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
jPanel2.add(jInternalFrame1, gridBagConstraints);
jSplitPane2.setRightComponent(jPanel2);
jPanel1.add(jSplitPane2);
jSplitPane1.setRightComponent(jPanel1);
getContentPane().add(jSplitPane1);
pack();
}
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
public static void main(String args[]) {
new Example().show();
}
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JSplitPane jSplitPane2;
private javax.swing.JTabbedPane jTabbedPane1;
}
I have a problem with JInternalFrame, recently.
I would like to create such a JInternalFrame, that wouldn't be able to move.
At the end there is a small program which demonstrates what am I thinking
about.
You can see that there are three "panels"
1. JDesktopPane
2. JPanel
3. JTabbedPane
You can also see, that only panel able to stop JInternalFrame from moving is
JTabbedPane.
Can anybody tell me if this is a some kind of a parameter (which determines
whether Frame is able to move or not) or maybe I have to work harder to
obtain such an efect?
Best regards,
Michal
/**
* code
*/
import java.awt.Dimension;
import javax.swing.DefaultDesktopManager;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;
public class Example extends javax.swing.JFrame {
public Example() {
initComponents();
JInternalFrame jif1 = new JInternalFrame("hello 1");
jif1.setVisible(true);
jTabbedPane1.add(jif1);
JInternalFrame jif2 = new JInternalFrame("hello 2");
jif2.setVisible(true);
jif2.setBounds(0,0, 200,100);
jDesktopPane1.add(jif2);
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jSplitPane1 = new javax.swing.JSplitPane();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jSplitPane2 = new javax.swing.JSplitPane();
jDesktopPane1 = new javax.swing.JDesktopPane();
jPanel2 = new javax.swing.JPanel();
jInternalFrame1 = new javax.swing.JInternalFrame();
getContentPane().setLayout(new java.awt.GridLayout(1, 1));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
jSplitPane1.setLeftComponent(jTabbedPane1);
jPanel1.setLayout(new java.awt.GridLayout(1, 1));
jSplitPane2.setLeftComponent(jDesktopPane1);
jPanel2.setLayout(new java.awt.GridBagLayout());
jInternalFrame1.setTitle("hello 3");
jInternalFrame1.setVisible(true);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
jPanel2.add(jInternalFrame1, gridBagConstraints);
jSplitPane2.setRightComponent(jPanel2);
jPanel1.add(jSplitPane2);
jSplitPane1.setRightComponent(jPanel1);
getContentPane().add(jSplitPane1);
pack();
}
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
public static void main(String args[]) {
new Example().show();
}
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JSplitPane jSplitPane2;
private javax.swing.JTabbedPane jTabbedPane1;
}