我在JDesktopPane中添加了两个JInternalFrame,假如是frame1,frame2,frame1占显示区域的2/3,frame2占显示区域的1/3,现在如何让这两个frame在整个Panel中不动呀,就是已经固定位置了,不能拖动,只能最小化和最大化,我实现了一个,但是能拖动,而且点击下面的那个frame2,此时它就会占据frame1的位置,还请高手指点.....
调试欢乐多
import java.awt.*;
import javax.swing.*;public class TestInternalFrame extends JApplet{
JButton connectButton = new JButton("Connect...");
JButton refreshButton = new JButton("Refresh");
JButton disconnectButton = new JButton("Disconnect...");
JDesktopPane desktopPane = new JDesktopPane();
JTextArea infoTextArea; public void init(){
//设定程序的LOOK&FEEL为Metal界面样式
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception e) {
e.printStackTrace();
}
//生成程序的GUI
Container contentPane = getContentPane();
JPanel controlPanel = new JPanel(); //容纳connect,refresh,disconnect按钮的面板
controlPanel.add(connectButton);
controlPanel.add(refreshButton);
controlPanel.add(disconnectButton);
contentPane.add(controlPanel, BorderLayout.NORTH); contentPane.add(desktopPane, BorderLayout.CENTER);
desktopPane.setLayout(new FlowLayout());
JInternalFrame treeFrame = new JInternalFrame("树型显示", false, false, true, false); //树型显示内部窗体
treeFrame.setPreferredSize(new Dimension(800, 450));
treeFrame.setVisible(true);
JInternalFrame infoFrame = new JInternalFrame("信息查看", false, false, true, false);
infoFrame.setPreferredSize(new Dimension(800, 150));
infoFrame.setLocation(0, 450);
infoFrame.setVisible(true);
JScrollPane treePanel = new JScrollPane(); //树型结构显示的面板区域
JScrollPane infoPanel = new JScrollPane(); //系统输出信息面板
infoTextArea = new JTextArea(); //系统输出信息区域
infoPanel.add(infoTextArea);
treeFrame.getContentPane().add(treePanel);
infoFrame.getContentPane().add(infoPanel);
desktopPane.add(treeFrame);
desktopPane.add(infoFrame);
}
}现在一运行,鼠标点击下面的信息窗口,两个窗口的位置就会发生错乱,到底怎么回事呀?请高手指点一下,急............