package Interface import java awt import java awt event ActionEvent im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package Interface;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import Interface.Plot;
import lgfGraph.*;
import javax.swing.table.DefaultTableModel;
public class Interface extends JFrame {
public static void main(String[] args) { new Interface(); }
{
JTabbedPane tabs = new JTabbedPane();
add(tabs);
JPanel tab1 = new JPanel();
JPanel tab2 = new Plot();
tabs.add("Опис графу", tab1);
tabs.add("Зображення графу", tab2);
JTable table = new JTable();
String data[][] = {{"1","2"},{"2","3"},{"3","1"}};
String col[] = {"Вершина 1","Вершина 2"};
final DefaultTableModel model = new DefaultTableModel(data,col);
table.setModel(model);
tab1.add(table);
JButton add_node = new JButton();
add_node.setText("Додати вершину");
tab1.add(add_node);
Action add_new_node = new javax.swing.AbstractAction("Button Label") {
public void actionPerformed(ActionEvent e) {
model.insertRow(model.getRowCount(),new Object[]{"1","1"});
}
};
add_node.setAction(add_new_node);
JButton del_node = new JButton();
del_node.setText("Видалити вершину");
tab1.add(del_node);
Action del_old_node = new javax.swing.AbstractAction("Button Label") {
public void actionPerformed(ActionEvent e) {
model.removeRow(model.getRowCount()-1);
//model.insertRow(model.getRowCount(),new Object[]{"1","1"});
}
};
del_node.setAction(del_old_node);
setSize(800,600);
setVisible(true);
//tab2.add(new Plot());
//tabs.add(new GraphPanel());
}
}