当前位置: 代码迷 >> Java相关 >> 为什么大小是固定的
  详细解决方案

为什么大小是固定的

热度:169   发布时间:2008-03-24 07:12:59.0
为什么大小是固定的
制定一个大小的Jpanel里面装两个list,list的大小怎么是固定的
让我很理解,我用setbounds setsize都没有用
很奇怪
!有人知道什么鸢鹰吗?
我把部分代码贴一下,由于是一个播放器,不能全贴看不懂!
listPanel = new JPanel();
        listPanel.setLayout(new BorderLayout());
        listPanel.setBounds(new Rectangle(4,150,289,148));
        listPanel.setBorder(BorderFactory.createEtchedBorder());
        leftList = new List();
        leftList.setBounds(new Rectangle(4,150,100,148));
        //leftList.setLocation(4, 150);
        //leftList.setSize(new Dimension(100,148));
        listPanel.add(new JScrollPane(leftList),BorderLayout.WEST);
        playList = new List();
        playList.setBounds(new Rectangle(100, 150, 189, 148));
        playList.addMouseListener(new MouseAdapter(){
            public void mouseClicked(MouseEvent e) {
                if(e.getClickCount() == 2){
                    playState();
                }
            }
        });
        listPanel.add(new JScrollPane(playList),BorderLayout.EAST);
        cp.add(listPanel);
        split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,leftList,playList);
        split.setBorder(new EmptyBorder(0,0,0,0));
        listPanel.add(split);
----------------解决方案--------------------------------------------------------
你应该把JScrollPane来setBounds
----------------解决方案--------------------------------------------------------
playListTitle = new JLabel();
        playListTitle.setBounds(new Rectangle(5,135,100,20));
        playListTitle.setText("PLAYLIST");
        cp.add(playListTitle);
        listPanel = new JPanel();
        listPanel.setLayout(new BorderLayout());
        //listPanel.setLayout(new FlowLayout());
        listPanel.setBounds(new Rectangle(4,150,289,148));
        listPanel.setBorder(BorderFactory.createEtchedBorder());
        leftList = new List();
        //leftList.setLocation(4, 150);
        //leftList.setBounds(new Rectangle(4,150,100,148));
        //leftList.setLocation(4, 150);
        //leftList.setSize(new Dimension(100,148));
        leftJScrollPanel = new JScrollPane(leftList);
        listPanel.add(leftJScrollPanel);
        playList = new List();
        playJScrollPanel = new JScrollPane(playList);
        playJScrollPanel .setBounds(new Rectangle(100, 150, 189, 148));
        playList.addMouseListener(new MouseAdapter(){
            public void mouseClicked(MouseEvent e) {
                if(e.getClickCount() == 2){
                    playState();
                }
            }
        });
        listPanel.add(playJScrollPanel);
        cp.add(listPanel);
        split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,leftJScrollPanel,playJScrollPanel );
        split.setBorder(new EmptyBorder(0,0,0,0));
        listPanel.add(split);
----------------解决方案--------------------------------------------------------
还是不行,感觉左边一个list大小定死了,拉过去的时候大小还是原来的一半!
----------------解决方案--------------------------------------------------------
往右边能拉,左边就脱不动了,大小是固定的,哪里出了问题?
----------------解决方案--------------------------------------------------------
往左拉会出现这种情况!
----------------解决方案--------------------------------------------------------
而且每次运行都不太一样

----------------解决方案--------------------------------------------------------
  相关解决方案