日期:2014-05-20  浏览次数:20602 次

在java中实现点击下拉列表自动改变文本框中的值,给个例子,谢谢!!
在java中实现点击下拉列表自动改变文本框中的值

------解决方案--------------------
可编辑的 JComboBox 就能满足这个要求
Java code
        JComboBox combo = new JComboBox();
        combo.setEditable(true);

------解决方案--------------------
探讨
可编辑的 JComboBox 就能满足这个要求

Java code
JComboBox combo = new JComboBox();
combo.setEditable(true);

------解决方案--------------------
问题不明确,文本框是一个单独的组件还是jcombobox自带的那个?
------解决方案--------------------
HTML code

<html>
    <head>
            <title>Simple</title>
            <script type="text/javascript">
                function change(){
                    var sel=document.getElementById("sel");
                    document.getElementById("tex").value=sel.options[sel.selectedIndex].value;
                }
            </script>
    </head>
    <body>
            <select id="sel" onchange ="change();">
                <option selected value="First">First</option>
                <option value="Second">Second</option>
                <option value="Third">Third</option>
            </select>
            <br/>
            <br/>
            <input type="text" id="tex" value="First" disabled="false" />
    </body>
</html>

------解决方案--------------------
好吧……我错了---
探讨
HTML code


<html>
<head>
<title>Simple</title>
<script type="text/javascript">
function change(){
var sel=document.getElementBy……