weixin_43781553
Tyrant of C
采纳率100%
2019-06-19 15:45

Java JComboBox下拉框点击后无法弹出 qiu'da'shen指点

图片说明
这两个下拉列表框一开始弹出后点击是无法弹出列表的,要鼠标点击一下窗体边框后才能弹出列表 新手小白不知道是什么原因

String[] sexList= {"男","女"};
        sexBox=new JComboBox<>(sexList);
        sexBox.setPreferredSize(new Dimension(120,25));
        String[] classList= {"一班","二班","三班","四班"};
        classBox=new JComboBox<>(classList);
        classBox.setPreferredSize(new Dimension(120,25));



        private void initLayout() {
        Panel idPanel=new Panel();
        idPanel.add(idLab);
        idPanel.add(idText);
        Panel namePanel=new Panel();
        namePanel.add(nameLab);
        namePanel.add(nameText);
        Panel sexPanel=new Panel();
        sexPanel.add(sexLab);
        sexPanel.add(sexBox);
        Panel classPanel=new Panel();
        classPanel.add(classLab);
        classPanel.add(classBox);
        Panel scorePanel=new Panel();
        scorePanel.add(scoreLab);
        scorePanel.add(scoreText);
        Panel remarkPanel=new Panel();
        remarkPanel.add(remarkLab);
        remarkPanel.add(remarkText);

        Panel mainPanel=new Panel();
        mainPanel.setLayout(new GridLayout(6,1));
        mainPanel.add(idPanel);
        mainPanel.add(namePanel);
        mainPanel.add(sexPanel);
        mainPanel.add(classPanel);
        mainPanel.add(scorePanel);
        mainPanel.add(remarkPanel);

        Panel southPanel=new Panel();
        southPanel.add(okBtn);
        southPanel.add(exitBtn);

        add(mainPanel,BorderLayout.CENTER);
        add(southPanel,BorderLayout.SOUTH);
    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答