Когато стартирам тази програма, имената на колоните ми не се показват. Опитах се да потърся грешката в Google, но изглежда никой не я има. Направих успешен масив за имената на данните и колоните, но все още не работи.
public class graphProgram extends JFrame {
private JPanel inputPanel, graphPanel, buttonPane;
private JTextField equationInput;
private JLabel equationLabel;
private JTable x_yValues;
private JButton calculateButton;
public graphProgram() {
super("Graph Calculator");
setSize(500, 500);
setLayout(new BorderLayout());
addComponents();
setVisible(true);
}
public void addComponents() {
String[] columnNames = {"X Values", "Y Values"};
Object[][] data = {{new Integer(-2), ""},
{new Integer(-1), ""},
{new Integer(0), ""},
{new Integer(1), ""},
{new Integer(2), ""},
{new Integer(3 ), ""}};
equationInput = new JTextField();
calculateButton = new JButton("Calculate");
equationLabel = new JLabel("Equation: ");
x_yValues = new JTable(data, columnNames);
inputPanel = new JPanel(new GridLayout(0, 2));
graphPanel = new JPanel(new GridLayout(0, 2, 5, 0));
buttonPane = new JPanel(new GridLayout(0, 1));
add(inputPanel, BorderLayout.NORTH);
add(graphPanel, BorderLayout.CENTER);
add(buttonPane, BorderLayout.SOUTH);
inputPanel.add(equationLabel);
inputPanel.add(equationInput);
graphPanel.add(x_yValues);
buttonPane.add(calculateButton);
}
}