开发者社区 问答 正文

关于按钮下拉列表的问题

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

展开
收起
蛮大人123 2016-02-20 18:33:36 1924 分享 版权
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
    赞同 展开评论
问答分类:
问答地址: