Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在netbeans框架中创建JList_Java_Swing_Jlist_Layout Manager - Fatal编程技术网

Java 在netbeans框架中创建JList

Java 在netbeans框架中创建JList,java,swing,jlist,layout-manager,Java,Swing,Jlist,Layout Manager,我正在用Netbeans制作一个Jlist,我已经编写了一段代码,但代码在我的Jlist中没有消失 /** Creates new form Toetsenbordd */ public Toetsenbordd() { initComponents(); initCustomComponents(); } private void initCustomComponents(){ JList Lijstje; JScro

我正在用Netbeans制作一个Jlist,我已经编写了一段代码,但代码在我的Jlist中没有消失

/** Creates new form Toetsenbordd */
    public Toetsenbordd() {
       initComponents();
        initCustomComponents();
    }

    private void initCustomComponents(){
     JList Lijstje;
     JScrollPane Lijst; 

         String filename[]= {"Ard ","Astronauts",
            "Behind the Scene Movie credits","DNA Research -- the Human Genome Project",
            "Extract from The Adventures of Pinocchio","History of Photography",
            "Hubble Space Telescope","Legends of Abraham Lincoln","Netiquette",
            "Observations of the Father of Computing (1791 - 1871)","Rules of Baseball (from 1889)",
            "Speeding up the strategy process","Stinging Insects","The Eight Tools for Creating New Values",
            "The Life of Calamity Jane","The Little Match Girl (adapted)","The Tail of Peter Rabbit",
            "Thoughts of Banjamin Franklin","What is the Cast","Yosemite National Park"
            };
        {

          Lijstje = new JList(filename);
          Lijstje.setFont(new Font("Arial",Font.PLAIN,15));
        Lijst =new JScrollPane(Lijstje);
        Lijst.setSize(410,200);
        Lijst.setLocation(70,75);
        Lijstje.setVisibleRowCount(6);
        Lijstje.setSelectedIndex(0);
        Lijstje.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        //seting the border for filescroll
        Lijst.setBorder(BorderFactory.createTitledBorder("CHOOSE TEST"));

        add(Lijst);

    }     



    }
它站在我自制的JFrime:


但是我想让它出现在第1、2、3项的位置。首先,请不要用大写字母开头变量名,这是违反规则的

代码中的
setLocation
表示希望您的
Lijst
具有绝对位置。这仅在不使用LayoutManager时才可能,请参阅。为此,您需要将布局管理器显式设置为
null
,因为
BorderLayout
是默认设置:

setLayout(null)

<>但不推荐使用<代码> null <代码>布局管理器,并且你确实应该考虑使用

中的一个。你的问题对于我来说并不清楚。你是在讨论如何布局两个JLIST??Toetsenbordd是什么?哪个类在中间扩展了JLIST,标题是不属于它的一个,这属于JLIST下,第1项必须通过示例来螫虫,ToeSeNbordd是我的JrFrm的名字。