2 Replies - 221 Views - Last Post: 20 March 2013 - 04:27 PM Rate Topic: -----

#1 b.netana  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 92
  • Joined: 11-September 11

question about getting jtable to display commission and possible commi

Posted 20 March 2013 - 01:20 AM

I have been trying to get my commission calculator to display the earnings and possible earnings in $5000 increments through a jtable. I have been unsuccessful thus far. Here is what I have for my table

import java.awt.*;
import javax.swing.*;

public class tableDemo extends JFrame {
	

	
	JTable table;
	
	public tableDemo() {
		
		comissionNumbers number = new comissionNumbers();
		
		double theSales = number.getSales();
		double theTotal = number.getTotal();
		
		setLayout(new FlowLayout());
		
		String[] columnNames = {"Total Sales" , "Total Compensation"};
		
		Object[][] data = {
			{theSales, theTotal}
				
		};
		
		table = new JTable(data, columnNames);
		table.setPreferredScrollableViewportSize(new Dimension(500, 100));
		table.setFillsViewportHeight(true);
		
		JScrollPane scrollPane = new JScrollPane(table);
		add(scrollPane);
	}
	public static void sub(String args[]) {
		tableDemo gui = new tableDemo();
		gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		gui.setSize(600, 200);
		gui.setVisible(true);
		gui.setTitle("Commission Calculator");
	}
}


this displays the 2 columns, but does not allow me to enter my values for calculation so there is nothing for the table to display in the two columns. Where might I be going wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: question about getting jtable to display commission and possible commi

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2644
  • View blog
  • Posts: 11,161
  • Joined: 20-September 08

Re: question about getting jtable to display commission and possible commi

Posted 20 March 2013 - 04:14 AM

You need to add rows to the table through your code
Was This Post Helpful? 1
  • +
  • -

#3 b.netana  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 92
  • Joined: 11-September 11

Re: question about getting jtable to display commission and possible commi

Posted 20 March 2013 - 04:27 PM

thank you, that seems to have been my issue.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1