Results 1 to 4 of 4

Thread: Help me

  1. #1
    Join Date
    Jul 2011
    Posts
    7
    Rep Power
    0

    Default Help me

    i get username from database to combobox.now combobox shows username.i need to select one item in combobox and need to code for that....here i am type one message and select one item from combobox and send message to selected item that in combobox.....so plz suggests me as u as possible.....thank uuuuu......

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    What's a combobox? There's no class by that name in the standard JDK.

    .....so plz suggests me as u as possible.....thank uuuuu.....
    Recommended reading: Write Well (edit: and the rest of that page)

    db

  3. #3
    Join Date
    Jul 2011
    Posts
    7
    Rep Power
    0

    Default

    combobox is not a class....that is one swing component.here i used in netbean.you can see the combobox in palette.....that palette in netbeans6.9

  4. #4
    Tamasa is offline Member
    Join Date
    Aug 2011
    Posts
    7
    Rep Power
    0

    Default

    Java Code:
    try
    		{
    			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    			Connection con=DriverManager.getConnection("jdbc:odbc:Master","sa","");
    			Statement st=con.createStatement();
    			ResultSet rs=st.executeQuery("select *from UsernameTable");
    			while(rs.next())
    			{
    				String p=rs.getString(1);
    				System.out.println(p);
    				jComboBox1.addItem(p);
    			}
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}

    Java Code:
    private void jComboBox1_actionPerformed(ActionEvent e)
    	{
    		System.out.println("\njComboBox1_actionPerformed(ActionEvent e) called.");
    		
    		Object o = jComboBox1.getSelectedItem();
    		 x=(String)o;
    		System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
                        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •