This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
dear programmers..... once again i fount trouble in my programme now i have trouble in get record from database and put one field in combo box.... i did it .. but sir when i use next , or last, or first etc button on my frame como value how comobo value change.. i 'm confuse sir here is its code [code] import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; import java.util.*;
First, you should fill in the Vector v with all the possible values that the combo box could hold. You would call the "setSelectedItem( newSelection );" method on your combo box whenever a new record was chosen.
The above method should be fine for most scenarios, but if you need to create different lists of possible values on the fly, you'll need to create a new DefaultComboBoxModel each time using the list of possible choices for the new record and then set it on your combo box using the "setModel( model );" method.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Sep 25, 2003
sirr i know that it will done through getSelectedIndex or getSelectedIndex but sir problem is this that what type of condition i can give it here.. how can i set its index and change value of other textfields thank u for replying
If you want to change the value in other text fields when the user selects a different value in the combo box, you can add either an ActionListener or an ItemListener to the combo box. An ActionListener receives an event whenever a new value is selected. An ItemListener receives an event for both the de-selection of an old item and the selection of the new item.
Joined: Sep 25, 2003
yes sirrr u r right.. but u see as i have made methods for every button so may i make another method for comobo box and apply on it ActionListener by gerSource()=combo.getSelectedIndex() but sir its logic is not clear in my mind .. i'm confuse about it, that how can i complete my work.