package gui;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import logic.Dijkstra;
import java.awt.Font;
public class Input {
private JFrame frame;
public JTable table;
public JTextArea bla;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Input window = new Input();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Input() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
public void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 595, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
},
new String[] {
"New column", "New column", "New column", "New column", "New column"
}
) {
Class[] columnTypes = new Class[] {
Double.class, Double.class, Double.class, Double.class, Double.class
};
public Class getColumnClass(int columnIndex) {
return columnTypes[columnIndex];
}
});
table.setBounds(23, 21, 209, 97);
frame.getContentPane().add(table);
JButton btnNewButton = new JButton("New button");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
double [][] help = new double [4][4];
for(int i=0;i<=4;i++){
for(int j=0;j<=4;j++){
if(table.getValueAt(i,j)!=null){
Object t = table.getValueAt(i,j);
String x = t.toString();
double y = Double.valueOf(x).doubleValue();
help[i][j] = y;
}
}
}
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if(table.getValueAt(i, j)!=null)
bla.append(String.valueOf(help[i][j]));
}
}
}
});
btnNewButton.setBounds(23, 154, 89, 23);
frame.getContentPane().add(btnNewButton);
bla = new JTextArea();
bla.setText("");
bla.setBounds(283, 21, 232, 190);
frame.getContentPane().add(bla);
}
}