开发者社区> 问答> 正文

关于按钮下拉列表的问题

点击一个按钮,它会下拉出一个按钮列表,Java代码应该怎么写?是用ListView么?求大神们帮帮忙啦

展开
收起
蛮大人123 2016-02-20 18:33:36 1840 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    应该是JToolBar,可以在上面放许多JButton

     Container contentPane=frame.getContentPane();
     toolBar=new JToolBar();
     button=new JButton[2];
     button[0] =new JButton(new FileAction("",icon_openFile,"open file"));
     button[1]=new JButton(new FileAction("",icon_saveFile,"save file"));
     button[0]=SetActionCommand("openFile");
     button[1]=SetActionCommand("saveFile");
     for(int i=0; i<button.length;i++){
     toolBar.add(button[i]);
     }
     contentPane.add(toolBar,BorderLayout.NORTH);
     return contentPane;
     }
    2019-07-17 18:45:40
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载