当前位置: 代码迷 >> Java相关 >> 一个奇怪的问题,我把完整的代码贴出来了,请大家看看!
  详细解决方案

一个奇怪的问题,我把完整的代码贴出来了,请大家看看!

热度:94   发布时间:2008-03-25 01:32:14.0
一个奇怪的问题,我把完整的代码贴出来了,请大家看看!
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.List;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;


public class PanelTest extends JFrame {
    private JPanel listPanel;
    private JScrollPane leftJScrollPanel;
    private JScrollPane playJScrollPanel;
    private List playList;
    private List leftList;
    private JSplitPane split;
    private Container cp;
    
    public PanelTest(){
        init();
    }
    
    
    public void init(){
        this.setSize(new Dimension(300, 379));
        this.setTitle("PLAYER");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setResizable(false);
        this.setLocation(200, 100);
        this.setVisible(true);
    }
    
    public void lunchFrame(){
        cp = getContentPane();
        listPanel = new JPanel();
        listPanel.setLayout(new BorderLayout());
        //listPanel.setLayout(null);
        //listPanel.setBounds(new Rectangle(4,150,289,148));
        listPanel.setLocation(4, 150);
        listPanel.setSize(new Dimension(289,148));
        listPanel.setBorder(BorderFactory.createEtchedBorder());
        leftList = new List();
        leftJScrollPanel = new JScrollPane(leftList);
        //leftJScrollPanel.setBounds(new Rectangle(4,150,100,148));
        listPanel.add(leftJScrollPanel,BorderLayout.WEST);
        playList = new List();
        playJScrollPanel = new JScrollPane(playList);
        //playJScrollPanel.setBounds(new Rectangle(100, 150, 189, 148));
        listPanel.add(playJScrollPanel,BorderLayout.EAST);
        split = new JSplitPane(SwingConstants.VERTICAL,true,leftJScrollPanel,playJScrollPanel );
        split.setBorder(new EmptyBorder(0,0,0,0));
        listPanel.add(split);
        cp.add(listPanel);
    }
    
    public static void main(String args[]){
        new PanelTest().lunchFrame();
    }
}
运行起来很奇怪!左边会盯死!
搜索更多相关的解决方案: import  awt  java  swing  代码  

----------------解决方案--------------------------------------------------------
不晓得楼主说的什么意思。
----------------解决方案--------------------------------------------------------
好像是list没办法吸附在滚动面板里面..伴随滚动面板一起动...
----------------解决方案--------------------------------------------------------
对啊,但是不知道怎么改正

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