samedi 20 juin 2015

How to use value obtained from user in one method to other method in same class

I get the value of EnterOrderID from abcd and I want to use it in fillCombobox, How can I achieve this ?

I am new in programming please help.

I tried setting it public still no luck

can someone please guide me through

 public class abcd extends JFrame {

   private JPanel contentPane;
   private JComboBox comboBoxRSU;
   public JTextPane EnterOrderID;
   /**
    * Launch the application.
    */


   Connection conn = null;

   /**
    * Create the frame.
    */
   public abcd() {



     EnterOrderID = new JTextPane();
     EnterOrderID.setContentType("integer");
     EnterOrderID.setBounds(114, 11, 224, 20);
     contentPane.add(EnterOrderID);


     JButton btnGetdetails = new JButton("Getdetails");
     btnGetdetails.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
           try {

             String query = "select distinct p.RM_ORDERID,s.VALID_VALUE as GID,t.TASK_NUMBER, p.INSITEA_CITY, p.ORDER_TYPE from data p,value s,task t where s.VALUE_LABEL = 'INDICATOR' and t.TASK_TYPE = 'LIS'and p.DOCUMENT_NUMBER = ?";
             PreparedStatement pst = conn.prepareStatement(query);
             pst.setString(1, (String) EnterOrderID.getText());
            //is is the value input by user  EnterOrderID 
            ResultSet rs = pst.executeQuery();

             while (rs.next()) {
               textFieldcrm.setText(rs.getString("RM_ORDERID"));
               textGID.setText(rs.getString("GID"));
               }

     );

     comboBoxRSU = new JComboBox();
     comboBoxRSU.setBounds(354, 74, 138, 20);
     contentPane.add(comboBoxRSU);
     fillComboBox();



   }

   public void fillComboBox() {

     try {
       String query = "select distinct s.VALID_VALUE as rsu,p.INSITEA_CITY from value s,data p  where s.VALUE_LABEL = 'GIS_RSU_DLC' and p.INSITEA_CITY = (select INSITEA_CITY from data where DOCUMENT_NUMBER = ?)";
       //(select INSITEA_CITY from data where DOCUMENT_NUMBER = ?)
       PreparedStatement pst = conn.prepareStatement(query);
       pst.setString(1, (String) EnterOrderID.getText());
      //Here I want to use it again, i do want user to input value again and again.        
      ResultSet rs = pst.executeQuery();

       while (rs.next()) {
         comboBoxRSU.addItem(rs.getString("rsu"));
       }

   }
 }

Aucun commentaire:

Enregistrer un commentaire