简体   繁体   English

需要帮助以Java创建下拉按钮

[英]Need help creating a drop down button with Java

I am fairly new to programming in Java. 我是Java编程的新手。 Currently I am trying to create a button that when clicked will produce a drop down. 目前,我正在尝试创建一个按钮,单击该按钮将产生一个下拉列表。 For example, you have a user input field that does a google type rolling search and separate from that is a button that when clicked will display a window to the right of it that brings up all available options. 例如,您有一个用户输入字段,该字段执行Google类型的滚动搜索,与此分开的是一个按钮,单击该按钮时将在其右侧显示一个窗口,该窗口弹出所有可用选项。

Here is my button: 这是我的按钮:

<input id = "mainContainer" type = "button" value = " + ";>

Is there a way to create a drop down menu after clicking the button with html or css? 用html或css单击按钮后,是否可以创建下拉菜单? Or does this need to be in javascript? 还是需要使用JavaScript?

It does not seem that difficult theoretically but I do not know much about java so I don't really have to much of a starting point. 从理论上讲似乎并不困难,但是我对java不太了解,因此我实际上并没有太多的起点。 I would believe that I would just need an onClick() event that will create a new menu. 我相信我只需要一个onClick()事件即可创建一个新菜单。 I just don't know how to write this out in java. 我只是不知道如何用Java写出来。 I Also need to complete this project in the next 2 weeks so any help will be greatly appreciated. 我还需要在接下来的2周内完成此项目,因此我们将不胜感激。

If you could provide code with an explanation of how it works I would be probably the happiest dude in the world. 如果您可以提供代码说明其工作原理,那么我可能是世界上最幸福的家伙。 Any reference would be appreciated. 任何参考将不胜感激。

您可以使用javascript编写自己的代码,也可以使用一些UI组件,例如: jQuery AutoComplete

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM