求助 我的JComboBox可以下拉,但不能显示下拉箭头了。

grubby4k 2009-11-10 05:15:20
 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));
}


用的是GridBagConstraint布局
...全文
200 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tsc2008 2010-02-25
  • 打赏
  • 举报
回复
今天用到JComboBox,需要将所有项删除,然后重新加,结果点出一个removeAll来,直接就用了。一运行才发现,连右边的下拉箭头也给remove掉了。惊出一身汗,赶紧查文档,唉,就在下面有一个removeAllItems方法。看来不看文档就是不行啊。特地拿出来,记住它

引用

removeAllItems
public void removeAllItems()
从项列表中移除所有项。



引用

removeAll
public void removeAll()从此容器中移除所有组件。此方法还通知布局管理器,通过 removeLayoutComponent 方法从此容器的布局中移除这些组件。
whut0802 2009-11-11
  • 打赏
  • 举报
回复
头有点晕。。。还是帮顶下
grubby4k 2009-11-11
  • 打赏
  • 举报
回复
顶一下
grubby4k 2009-11-10
  • 打赏
  • 举报
回复
怎么就没人呢~?这么诡异的问题呀
grubby4k 2009-11-10
  • 打赏
  • 举报
回复
顶一下~

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧