Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT i have JTextfield and JComboBox. there are several values in combobox.when i select a value from combobox how to make textfiled as a combobox.

Have Programming Question? Ask it here!
 
 
 


raveen
i have JTextfield and JComboBox. there are several values in combobox.when i select a value from combobox how to make textfiled as a combobox.
1 Answer(s)      a year and 7 months ago
Posted in : Swing AWT


i have JTextfield and JComboBox. there are several values in combobox.when i select a value from combobox how to make textfiled as a combobox.


Advertisement
View Answers

December 18, 2012 at 12:11 PM


Here is an example that shows the selected value from the jcombobox to textfield.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class  SelectComboboxValue{

    public static void main(String[] args) throws Exception{
        JFrame f=new JFrame();
        f.setLayout(null);
        JLabel lab=new JLabel("Select Programming Language: ");
        final JComboBox combo=new JComboBox();
        final JTextField text=new JTextField(20);
        combo.addItem("--Select--");
           combo.addItem("Java");
           combo.addItem("C/C++");
           combo.addItem(".NET");
           combo.addItem("Perl");


        ActionListener actionListener = new ActionListener(){
        public void actionPerformed(ActionEvent actionEvent) {
        ItemSelectable is = (ItemSelectable)actionEvent.getSource();
        String st=selectedString(is);
        text.setText(st);
        //JOptionPane.showMessageDialog(null,"You have Selected: " + name);
        }
    };
       combo.addActionListener(actionListener);
        lab.setBounds(20,20,200,20);
        combo.setBounds(200,20,80,20);
        text.setBounds(280,20,100,20);
        f.add(lab);
        f.add(combo);
        f.add(text);

        f.setVisible(true);
        f.setSize(400,120);
    }
    static private String selectedString(ItemSelectable is) {
    Object selected[] = is.getSelectedObjects();
    return ((selected.length == 0) ? "null" : (String)selected[0]);
  } 
}


Related Tutorials/Questions & Answers:
issue on jcombobox
issue on jcombobox  i have JTextfield and JComboBox. there are several values in combobox.when i select a value from combobox how to make textfiled as a combobox.only few values in the combobox need this functionality. need
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
Advertisements
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.  I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid
How to make addition of two combobox values using jsp and javascript?
addition of two combobox values using jsp and javascript  How to make addition of two combobox values using jsp and javascript?  <...++) { var option = document.createElement("option"); option.setAttribute('value',i+1
Java swing: get selected value from combobox
Java swing: get selected value from combobox In this tutorial, you will learn how to get selected value from combobox. The combobox provides the list... of programming languages to the combobox using addItem() of JComboBox class. We have
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
I am not able to display the selected value of my combobox
;/option>"; $select.="<option name='unitcode' value=\"".$myrow['$i...I am not able to display the selected value of my combobox   <?php echo "<select name=\"hello\">\n"; echo "<option value=\"NULL\">
how I do select from select in hql
how I do select from select in hql  select RN from ( select rownum RN, dbid from ( select * from profile p where type = 1912 and name like... doesn't work select RN from ( select rownum RN, DBId from ( select distinct p
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
values in combobox - Java Beginners
values in combobox  how to fill values in combo box i.e. select tag...: ComboBox var arr = new Array(); arr[0] = new Array("-select-"); arr[1...; for (var i=0;i
Passing values in ComboBox from XML file
Passing values in ComboBox from XML file In this tutorial we are going to know how we can pass a values in ComboBox by using XML.  This example... the data from the XML file and insert it into the ComboBox. To make a program over
how to use an editable combobox
how to use an editable combobox   Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
How to Connect J ComboBox with Databse - Java Beginners
How to Connect J ComboBox with Databse  How to Connect J ComboBox with Databse  Hi Friend, Do you want to get JComboBox values from database?Please clarify this. Thanks
combobox
combobox  In dashboar.jsp form, When i click employee id value... stored combo box values from database. can u pls tell me the proceduer to get...=con.createStatement(); ResultSet rs=st.executeQuery("select * from
combobox
combobox  i have three tables in database country,state and city... depends on state i have implmnt dis code and it work propely bt problem is the field...;option value=''>select country</option> <
combobox
combobox  i have three tables in database country,state and city... depends on state i have implmnt dis code and it work propely bt problem is the field...;option value=''>select country</option> <
combobox
combobox  Hi, i have one combo Box with 5 options and one Other option also there,when i select a other i need to get a new text box for entering user option and when click on submit it should save on same field in database
Combobox jsp from 0 to 10
Combobox jsp from 0 to 10  Hi guys please help me to write a very easy program using jsp to display value in combobox from 0 to 10. How to write...;% for(int i=0;i<=10;i++){ %> <option value="<%=i%>"><%=i%><
easy way to make a JCombobox look like a JTextField?
easy way to make a JCombobox look like a JTextField?  Is there a good(and easy) way to make a JCombobox look like a JTextField? By this I mean there should not be a dropdown button, but when the user enters something it should
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
a value in combobox.   I have the same problem.plz help me. I have MySQL... have to display the Nodename and packageno. i.e.,select nodename,packageno from...; Values(crs,cs 4.0,xxx), Values(sdp,cs 5.0,yyy), Values(air,cs 6.0,zzz), i want
Database values in JComboBox
Database values in JComboBox In this section, you will learn how to display values in JComboBox from database. For this, we have allowed the user to enter any character as a key in the textbox .Based on this key value, the results from
Java Swing dynamic Combobox
Java Swing dynamic Combobox In this section, you will learn how to display the data in one combobox related to another combobox. For this, we have created two combo boxes. In the first combobox, we have added four items. When the user
Combobox in HTML
the options in the list. Here is how to make a simple Combobox in HTML: <html>...Combobox in HTML is used to display a drop-down list of some options from...;select> <option value="Select">Select....</option> <option
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
fill combobox at runtime jsp
fill combobox at runtime jsp  i have 1 combobox in jsp which is filled with value from sql db on load of form <% Class.forName... another combobox below it, i want it to be filled on the basis of selected value
How to declare a Combobox without using a string in its declaration?
How to declare a Combobox without using a string in its declaration?  What i mean to ask is how can i declare a combobox first and initialise the values later? For example JComboBox x= new JComboBox(); ... String s={"Alpha
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
is how to get Roleid in textbox when i select Role_name from combobox in a same...HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE ... Roleid and Role_name. and values are Roleid Role_name 1
i want validation for one text field and text area,email,combobox, in that email will validte by useing regular expressions?
i want validation for one text field and text area,email,combobox, in that email will validte by useing regular expressions?  i want validation for one text field and text area,email,combobox, in that email will validte by useing
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
i want to select a multiple value of check box by using onclick or onchange event without using from submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission   i have 4 check box name 1)profile...)1000-1500 3)1500-2000 4)2000-2500 when i am selecting first value of checkbox
I have to retrieve these data from the field table
as single values like chennai as one value, trichy as one value. and i have...I have to retrieve these data from the field table  Hi. I have... chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
how to make employee i card
how to make employee i card  hello friends can anyone help me.. I have to make a project to make Identity card for employees...but i am facing..."); Statement stmt=con.createStatement(); String strQuery = "select * from data
Display JList value selected from the JOptionPane
Display JList value selected from the JOptionPane In this section, we are going to select the particular value from the JOptionPane combobox and displayed that value in the JList. For this purpose, we have created a button and JList
JComboBox
JComboBox  I want to change the index of one jComboBox according to the selected index of another jComboBox. I can do it.Also the user should have the ability to select or change the index of the second combobox according
jComboBox
jComboBox  I want to change the index of one jComboBox according to the selected index of another jComboBox. I can do it.Also the user should have the ability to select or change the index of the second combobox according
Combobox program - Java Beginners
"); JComboBox jc=new JComboBox(); jc.addItem("Select"); jc.addItem("MCA... in combobox a new text box have to open beside that combo box..  Hi...=new JComboBox(); jc.addItem("Select"); jc.addItem("MCA"); jc.addItem("MBA
editable combobox method selection
editable combobox method selection  how to make an editable combobox... an item starting with that letter, subsequent keys would keep sorting from the list. just like we get when we select method for an object in an IDE
Non-edit Combobox with auto fill - Swing AWT
Non-edit Combobox with auto fill  Hi, I have a non-edit...-editable mode of JCombobox, For ex: If user type "Ch" JCombobox should select "Charls", If user type "Chi", JCombobox should select "Chim". I tried to catch
jsp combobox
..if i select one country throug combo box than other combobox show state only select country ...than city how i can implement through jsp   1...(); ResultSet rs = stmt.executeQuery("Select * from country"); while(rs.next
pbml in inserting selected item from combobox into mysql - XML
pbml in inserting selected item from combobox into mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..  how to output text from comboBox from first frame to textField on the second frame? please help me
combobox updation - Java Beginners
combobox updation  hi, i am using java swing to develop a gui... in a different panel. the problem is on clicking of 2nd combobox-i am not getting the item... as possible. it's been a long time now tht i have been breaking my head on....i knw d
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java... where i have to select multiple keyskills. but it is taking only one valuee.. i... is displaying.. i need code in java so that it takes multiple values
retrieve Dept Name from table dept and retrieve list of employee from emp table for that dept in combobox
for that dept in combobox  I have an 2 textboxes and 1 combobox in my... of employee from table emp for that dept in combobox using this query (select ename... and display that list in combobox. For example, In HTML page, we have Dept ID
two linked combobox
two linked combobox  give jsp example of two combo box when i select state in one combobox in second combo box cities will display according to state which i select
 

 

 

DMCA.com