hye...I'm having a problem to retrieve data from Jcombo Box...
the combo box have a list from A-Z..for example when the user pick 'A' from the list,it will get all the A% data from MySQL

this is the code that i have right now.

JButton Edit = new JButton ("EDIT SYNONYM");
                Edit.setMnemonic('d');
		Edit.addActionListener(
                new ActionListener()
		{   JButton BACK;

                    public void actionPerformed(ActionEvent e)
			{

                         JFrame alphabet=new JFrame("Malay Synonym Word Checker - EDIT WORD");
                         alphabet.getContentPane().setLayout(null);
                         JLabel lbl1 = new JLabel("Select alphabet");
                         final String [] alpha = {"a","b","c","d","e","f","g","h","i","j","k","l","m" ,"n","o","p","q","r","s","t","u","v","w","x","y","z"};
                         JComboBox huruf= new JComboBox(alpha);
                         JLabel lbl2 = new JLabel("Words");
                         final JTextField jt1=new JTextField(15);
                         huruf.setSelectedIndex(0);
                         lbl1.setBounds(50,50,100,20);
                         huruf.setBounds(170,50,100,20);
                         lbl2.setBounds(50,80,70,20);
                         jt1.setBounds(170,80,100,20);
                         
                         huruf.addActionListener(new ActionListener() {                         
                          public void actionPerformed(ActionEvent e) {
                              ItemSelectable is = (ItemSelectable)e.getSource();
                               String st= selectedString(is);
                               try{
                                   
                                 Class.forName("com.mysql.jdbc.Driver");
                                 Connection con = DriverManager.getConnection("jdbc:mysql://localhost/finalproject", "root", "pwd");
                                 Statement st=con.createStatement();
                                 String pick = "select * from synonym where words like =%'"+st+"'";
                                 
                                 }
                              

                          

                        }

                    });

                    
                }

                alphabet.setLayout(new BorderLayout());
                BACK = new JButton("Back");
                BACK.setBounds(340, 170, 83, 28);

                alphabet.add(BACK, BorderLayout.SOUTH);
                
                alphabet.add(BACK, BorderLayout.SOUTH);
                
                alphabet.setVisible(true);
                alphabet.setSize(450,250);
                    }
                }
                );

That statement reads as follows

= %'A'

you wanted

= 'A%'

correct?

That statement reads as follows

= %'A'

you wanted

= 'A%'

correct?

no,what i mean is the system will get the input from the user...

masjiade was referring to this:

String pick = "select * from synonym where words like =%'"+st+"'";

are you sure you don't need to place the % behind the user selected String?

masjiade was referring to this:

String pick = "select * from synonym where words like =%'"+st+"'";

are you sure you don't need to place the % behind the user selected String?

yup2...what i want is A%....sorry2..i get confused..huhu~

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.