Click here to Skip to main content
14,270,447 members
   

Java

 
PinnedForum Guidelines - PLEASE READ Pin
Chris Maunder28-Jul-09 2:36
adminChris Maunder28-Jul-09 2:36 
QuestionRestaurant Reservation java code Pin
Member 1456547722hrs 11mins ago
memberMember 1456547722hrs 11mins ago 
AnswerRe: Restaurant Reservation java code Pin
Richard MacCutchan22hrs 5mins ago
protectorRichard MacCutchan22hrs 5mins ago 
QuestionRecommendation: Learn from GITHUB project Pin
Anisul Huq7-Aug-19 18:20
memberAnisul Huq7-Aug-19 18:20 
AnswerRe: Recommendation: Learn from GITHUB project Pin
Richard MacCutchan7-Aug-19 22:04
protectorRichard MacCutchan7-Aug-19 22:04 
Questionhow to use class for sending notification in android? Pin
Member 145520336-Aug-19 2:53
memberMember 145520336-Aug-19 2:53 
QuestionMy Simple servlet is called twice, i dont know why. Pin
yinallier15-Aug-19 20:27
memberyinallier15-Aug-19 20:27 
AnswerRe: My Simple servlet is called twice, i dont know why. Pin
Gerry Schmitz6-Aug-19 5:50
mveGerry Schmitz6-Aug-19 5:50 
QuestionJavaFX CSS "dynamic" value not being used Pin
Valentinor2-Aug-19 23:03
memberValentinor2-Aug-19 23:03 
AnswerRe: JavaFX CSS "dynamic" value not being used Pin
Valentinor10-Aug-19 0:58
memberValentinor10-Aug-19 0:58 
QuestionJava Derby Database Pin
Gregory Guy30-Jul-19 20:16
memberGregory Guy30-Jul-19 20:16 
AnswerRe: Java Derby Database Pin
Richard MacCutchan30-Jul-19 21:16
protectorRichard MacCutchan30-Jul-19 21:16 
QuestionMessage Closed Pin
25-Jul-19 0:22
professionalVivid Colors25-Jul-19 0:22 
QuestionAnnotation Processing - Generating Files at Each Round vs at Last Round Pin
Abbas A. Ali3-Jul-19 19:44
professionalAbbas A. Ali3-Jul-19 19:44 
QuestionBasic Calculator Write a program that works as a simple calculator. 1.It reads a character (ch) 2.If ch is among '+', '-', '*', '/' or '%' it furthur takes two numbers (N1 and N2 as input). It then performs appropriate appropriate operation between n Pin
Member 1450000613-Jun-19 22:55
memberMember 1450000613-Jun-19 22:55 
AnswerRe: Basic Calculator Write a program that works as a simple calculator. 1.It reads a character (ch) 2.If ch is among '+', '-', '*', '/' or '%' it furthur takes two numbers (N1 and N2 as input). It then performs appropriate appropriate operation betwe Pin
Richard Deeming14-Jun-19 0:55
mveRichard Deeming14-Jun-19 0:55 
AnswerRe: Basic Calculator Write a program that works as a simple calculator. 1.It reads a character (ch) 2.If ch is among '+', '-', '*', '/' or '%' it furthur takes two numbers (N1 and N2 as input). It then performs appropriate appropriate operation betwe Pin
Richard MacCutchan14-Jun-19 1:06
protectorRichard MacCutchan14-Jun-19 1:06 
QuestionFailed to grab focus on a Jtextfield Pin
Member 1413007922-May-19 4:06
memberMember 1413007922-May-19 4:06 
SuggestionRe: Failed to grab focus on a Jtextfield Pin
Richard MacCutchan22-May-19 21:32
protectorRichard MacCutchan22-May-19 21:32 
GeneralRe: Failed to grab focus on a Jtextfield Pin
Member 1413007923-May-19 1:07
memberMember 1413007923-May-19 1:07 
GeneralRe: Failed to grab focus on a Jtextfield Pin
Richard MacCutchan23-May-19 1:44
protectorRichard MacCutchan23-May-19 1:44 
Questioncloudsim algorithm Genitic Pin
Member 1423906220-May-19 8:20
memberMember 1423906220-May-19 8:20 
AnswerRe: cloudsim algorithm Genitic Pin
Richard MacCutchan20-May-19 22:09
protectorRichard MacCutchan20-May-19 22:09 
QuestionHow can i make Jtexfield updates when Jtable values are changed? Pin
Member 141300798-May-19 2:36
memberMember 141300798-May-19 2:36 
Hey guys i have a Jtable shown as : IdP | NameProduct | Quantity | Price |Stock

i have created this method :
public  int calculatesum(){
        int total=0; 
             for(int i=0;i<table.getRowCount();i++){
                 
                  
            
                   int  amount = Integer.parseInt((String)table.getValueAt(i, 2).toString());
                   int amprice = Integer.parseInt((String)table.getValueAt(i, 3).toString());
                   total=total+(amount*amprice);
                     
            
            }
             
             return total;
             
    }


that calculates multipilication of (Price*Quantity) and put result in a Jtexfield and called this method in a button action:
private void buttonsearchActionPerformed(java.awt.event.ActionEvent evt) {                                             

        conn = DatabaseConnection.dbConnection();
        try {
                    String Sql="select idp,nomp,prix,stock from produit where codep='" + textsearch.getText() + "'";
                    pst = conn.prepareStatement(Sql);


            ResultSet rs = pst.executeQuery();
            
            Object[] columns = {"Id Produit", "Nom Produit", "Quantité", "Prix", "Stock"};
        
            Object[] row = new Object[5];
            if (rs.next()){
            row[0] = rs.getInt("idp");
            row[1] = rs.getString("nomp");
            row[2] = 1;
            row[3] = rs.getString("prix");
            row[4] = rs.getString("stock");
           
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            model.addRow(row);}
            //table.repaint();
            
            calculatesum();
            pricetext.setText(Integer.toString(calculatesum()));

          
             
            

        } catch (Exception e) {

            JOptionPane.showMessageDialog(null, e);

        }
        


                    

    }             


My problem is: any changes on quantity won't update the Jtextfield automatically until the button is pressed again. so How can i make the Jtextfield (aka result) changes on the time i change quantity
thanks for help
AnswerRe: How can i make Jtexfield updates when Jtable values are changed? Pin
Richard MacCutchan8-May-19 2:48
protectorRichard MacCutchan8-May-19 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.