Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By doWhile

Thread: JTable

  1. #1
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default JTable

    Hi guys..........

    I am working on a Inventory System witch has JTable linked with mysql the table able to display all the information witch mysql table has.. the JTable has 2 column (item and price ) and a JTextField to show the total and a JButton (sub total)

    my problem is when I press the sub-total button. the program should add all the price witch Jtable has and should displayed to Jtextfield

    Thanks

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    Post some code that demonstrates the problem you are having (preferable an SSCCE), and please describe the problem in more detail (did you implement your requirement? does it compile? are there exceptions? Does it behave?)
    Fubarable likes this.

  3. #3
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by doWhile View Post
    Post some code that demonstrates the problem you are having (preferable an SSCCE), and please describe the problem in more detail (did you implement your requirement? does it compile? are there exceptions? Does it behave?)
    everything work fine
    i did try smthing like this

    The values in JTable (Price )

    1st value 24.99
    2nd value 10.99
    3rd value 1.99
    4th value 250
    5th value 24.99
    6th value 3.99



    Java Code:
    ok.addActionListener(new ActionListener() {
    			
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				// TODO Auto-generated method stub
    				
    				for(int row=0; row<table.getRowCount(); row++){
    					Object o= table.getValueAt(row, 1);
    					
    					
    					
    					String str = o.toString();
    					Double d = Double.valueOf(str).doubleValue();
    					//System.out.println(d);
    					tot2=d;
    					add=tot2+d;
    					subtot=add+tot2;
    					System.out.println("Total="+subtot);
    				}
    				
    			}
    		
    		});
    out put is like this

    Java Code:
    Total=74.97
    Total=32.97
    Total=5.97
    Total=750.0
    Total=74.97
    Total=11.97
    Subtotal==11.97
    Last edited by razmyasdfg; 06-10-2011 at 12:32 AM.

  4. #4
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by doWhile View Post
    Post some code that demonstrates the problem you are having (preferable an SSCCE), and please describe the problem in more detail (did you implement your requirement? does it compile? are there exceptions? Does it behave?)

    Sorry Guys i solved the problem..... i was bit confused with for loop

    thank you everyone

  5. #5
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default Solved

    Sorry Guys i solved the problem..... i was bit confused with for loop

    thank you everyone

Similar Threads

  1. need a little help on JTable
    By syst3m.tr0jan in forum AWT / Swing
    Replies: 1
    Last Post: 02-04-2011, 06:28 AM
  2. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 08:27 AM
  3. JTable
    By ivvgangadhar in forum AWT / Swing
    Replies: 1
    Last Post: 07-26-2009, 04:59 AM
  4. Add a row in JTable
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 04-15-2009, 08:48 PM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 AM

Posting Permissions

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