【高分求解】诡异问题:JComboBox可以下拉,但没有下拉箭头

时间:2021-04-01 18:06:36
private void jbInit()
    {
        this.getContentPane().add(pnlMain);
        pnlMain.setLayout(borderLayout1);
        pnlMain.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
        pnlMain.add(pnlCenter, BorderLayout.CENTER);
        pnlMain.add(pnlSouth, BorderLayout.SOUTH);
        pnlSouth.setLayout(flowLayout1);
        flowLayout1.setAlignment(FlowLayout.RIGHT);
        pnlSouth.add(btnRefresh);
        pnlSouth.add(btnSet);
        pnlSouth.add(btnClose);
        pnlSouth.add(btnHelp);
        btnRefresh.setText("刷新");
        btnRefresh.setSize(new Dimension(83, 23));
        btnRefresh.setMnemonic('R');
        btnRefresh.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnRefresh_actionPerformed(e);
            }
        });
        btnSet.setText("设置");
        btnSet.setSize(new Dimension(83, 23));
        btnSet.setMnemonic('S');
        btnSet.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnSet_actionPerformed(e);
            }
        });
        btnClose.setText("关闭");
        btnClose.setSize(new Dimension(83, 23));
        btnClose.setMnemonic('C');
        btnClose.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnClose_actionPerformed(e);
            }
        });
        btnHelp.setText("帮助");
        btnHelp.setSize(new Dimension(83, 23));
        btnHelp.setMnemonic('H');
        btnHelp.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                btnHelp_actionPerformed(e);
            }
        });
        
        pnlCenter.setLayout(borderLayout2);
        pnlCenter.setBorder(border1);
        pnlCenter.add(pnlCNorth, BorderLayout.NORTH);
        pnlCenter.add(pnlCCenter, BorderLayout.CENTER);
        pnlCenter.add(pnlCSouth, BorderLayout.SOUTH);
        pnlCNorth.setBorder(border2);
        pnlCNorth.setLayout(gridBagLayout1);
        lblZxAnMldAdminStatus.setText("MLD协议使能");
        lblZxAnMldAging.setText("老化时间");
        lblZxAnMldWorkingMode.setText("工作模式");
        lblZxAnMldMcastInAllVlan.setText("跨VLAN使能");
        lblZxAnMldBandwidthCtrl.setText("带宽使能");
        lblZxAnMldHostTrackOnOff.setText("主机跟踪使能");
        lblZxAnMldGeneralLeaveGrpAddr.setText("通用离开组播地址");
        lblZxAnMldGroupThreshold.setText("最大组播组门限");
        pnlCNorth.add(lblZxAnMldAdminStatus, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(cmbZxAnMldAdminStatus, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldAging, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(txtZxAnMldAging, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldWorkingMode, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(cmbZxAnMldWorkingMode, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldMcastInAllVlan, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(cmbZxAnMldMcastInAllVlan, new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldBandwidthCtrl, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(cmbZxAnMldBandwidthCtrl, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldHostTrackOnOff, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(cmbZxAnMldHostTrackOnOff, new GridBagConstraints(3, 2, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldGeneralLeaveGrpAddr, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(txtZxAnMldGeneralLeaveGrpAddr, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(lblZxAnMldGroupThreshold, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCNorth.add(txtZxAnMldGroupThreshold, new GridBagConstraints(3, 3, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));

        pnlCCenter.setBorder(border3);
        pnlCCenter.setLayout(gridBagLayout2);
        lblZxAnMldRobustnessVariable.setText("健壮性变量");
        lblZxAnMldQueryInterval.setText("查询间隔");
        lblZxAnMldQueryMaxResponseTime.setText("查询最大响应时间");
        lblZxAnMldLastMembQueryInterval.setText("最后成员查询间隔");
        lblZxAnMldLastMembQueryCount.setText("最后成员查询记数");
        lblZxAnMldUnsolicitedReportInterv.setText("主动报告间隔时间");
        pnlCCenter.add(lblZxAnMldRobustnessVariable, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(cmbZxAnMldRobustnessVariable, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(lblZxAnMldQueryInterval, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(txtZxAnMldQueryInterval, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(lblZxAnMldQueryMaxResponseTime, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(txtZxAnMldQueryMaxResponseTime, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(lblZxAnMldLastMembQueryInterval, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(txtZxAnMldLastMembQueryInterval, new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(lblZxAnMldLastMembQueryCount, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(cmbZxAnMldLastMembQueryCount, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(lblZxAnMldUnsolicitedReportInterv, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCCenter.add(txtZxAnMldUnsolicitedReportInterv, new GridBagConstraints(3, 2, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCSouth.setBorder(border4);
        pnlCSouth.setLayout(gridBagLayout3);
        lblZxAnMcastIpv6CdrServerIP.setText("接收服务器地址");
        lblNull1.setText("     ");
        lblNull2.setText("     ");
        pnlCSouth.add(lblZxAnMcastIpv6CdrServerIP, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCSouth.add(txtZxAnMcastIpv6CdrServerIP, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
            , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 6, 6), 0, 0));
        pnlCSouth.add(lblNull1,  new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
        pnlCSouth.add(lblNull2,  new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
            , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 6), 0, 0));
    }


这是构造GUI的方法~布局时GridBagConstraints

13 个解决方案

#1


应该是少设定了某个属性

#2


是指JComboBox的属性 还是布局上的属性

我发现不在该布局内的JComboBox是好的~

#3


你最好把你的pnlCNorth,gridBagLayout1还有comboBox的初期化代码贴出来看看

#4


JPanel pnlCNorth = new JPanel();

GridBagLayout gridBagLayout1 = new GridBagLayout();

JComboBox cmbZxAnMldAdminStatus = new JComboBox();


#5


求解呀

#6


dingyixia

#7


引用 4 楼 grubby4k 的回复:
JPanel pnlCNorth = new JPanel();

 GridBagLayout gridBagLayout1 = new GridBagLayout();

 JComboBox cmbZxAnMldAdminStatus = new JComboBox();


这是你初期化代码,没有设置任何属性是么?

#8


该回复于2009-11-13 08:56:28被版主删除

#9


曾经有过布局管理器布局导致空间无法正常显示 和只显示一部分的 
没有显示更加难找 显示不完全就肯定是 被布局管理器给郁闷了 而且很有可能是流布局管理器的问题

#10


我也能定位是布局管理器的问题,但是如何解决呢?

#11


栓查清空的方法,看用的是不是removeAll,如果是的话就替换成removeAllItems

#12


该回复于2009-12-21 20:04:30被版主删除

#13


引用 11 楼 a3880012 的回复:
栓查清空的方法,看用的是不是removeAll,如果是的话就替换成removeAllItems

嗯,这个必须得改

#1


应该是少设定了某个属性

#2


是指JComboBox的属性 还是布局上的属性

我发现不在该布局内的JComboBox是好的~

#3


你最好把你的pnlCNorth,gridBagLayout1还有comboBox的初期化代码贴出来看看

#4


JPanel pnlCNorth = new JPanel();

GridBagLayout gridBagLayout1 = new GridBagLayout();

JComboBox cmbZxAnMldAdminStatus = new JComboBox();


#5


求解呀

#6


dingyixia

#7


引用 4 楼 grubby4k 的回复:
JPanel pnlCNorth = new JPanel();

 GridBagLayout gridBagLayout1 = new GridBagLayout();

 JComboBox cmbZxAnMldAdminStatus = new JComboBox();


这是你初期化代码,没有设置任何属性是么?

#8


该回复于2009-11-13 08:56:28被版主删除

#9


曾经有过布局管理器布局导致空间无法正常显示 和只显示一部分的 
没有显示更加难找 显示不完全就肯定是 被布局管理器给郁闷了 而且很有可能是流布局管理器的问题

#10


我也能定位是布局管理器的问题,但是如何解决呢?

#11


栓查清空的方法,看用的是不是removeAll,如果是的话就替换成removeAllItems

#12


该回复于2009-12-21 20:04:30被版主删除

#13


引用 11 楼 a3880012 的回复:
栓查清空的方法,看用的是不是removeAll,如果是的话就替换成removeAllItems

嗯,这个必须得改