From 54d76581f33935bd3a264725016b95d9f6e6055e Mon Sep 17 00:00:00 2001 From: Tergel TSAGAAN Date: Thu, 24 Dec 2020 21:02:10 +0100 Subject: [PATCH] backup --- config.json | 1 + src/main/java/GUI/GUI.form | 169 ++++++++++++++++++++++++---- src/main/java/GUI/GUI.java | 51 ++++++++- src/main/java/GUI/MyTableModel.java | 27 +++++ 4 files changed, 223 insertions(+), 25 deletions(-) create mode 100644 config.json create mode 100644 src/main/java/GUI/MyTableModel.java diff --git a/config.json b/config.json new file mode 100644 index 0000000..16cb637 --- /dev/null +++ b/config.json @@ -0,0 +1 @@ +{"host":"vps.flifloo.fr","password":"cannes","database":"cannes","user":"root"} \ No newline at end of file diff --git a/src/main/java/GUI/GUI.form b/src/main/java/GUI/GUI.form index 819c572..3cdfae1 100644 --- a/src/main/java/GUI/GUI.form +++ b/src/main/java/GUI/GUI.form @@ -1,45 +1,166 @@
- - + - + - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - diff --git a/src/main/java/GUI/GUI.java b/src/main/java/GUI/GUI.java index 77773b8..d14cff5 100644 --- a/src/main/java/GUI/GUI.java +++ b/src/main/java/GUI/GUI.java @@ -1,15 +1,62 @@ package GUI; import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableModel; +import java.awt.*; public class GUI extends JFrame { private JPanel mainPanel; - + private JButton LMButton; + private JButton HCButton; + private JButton UCRButton; + private JTable table1; + private JScrollPane scrollPane; + private JTable table2; + private JMenuBar menuBar = new JMenuBar(); + private JMenu menuFichier = new JMenu("File"); + private JMenuItem menuItemAddProj = new JMenuItem("Add projection"); + private JMenuItem menuItemEditProj = new JMenuItem("Edit projection"); + private JMenuItem menuItemRemoveProj = new JMenuItem("Remove projection"); public GUI() { super(); construct(); } + private void renderMenu() { + menuBar.add(menuFichier); + menuFichier.add(menuItemAddProj); + menuFichier.add(menuItemEditProj); + menuFichier.add(menuItemRemoveProj); + setJMenuBar(menuBar); + } + private void renderTable() { + DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); + centerRenderer.setHorizontalAlignment(SwingConstants.CENTER); + TableModel dataTest = new MyTableModel(); + table1.setModel(dataTest); + for (int columnIndex = 0; columnIndex < dataTest.getColumnCount(); columnIndex++) + { + table1.getColumnModel().getColumn(columnIndex).setCellRenderer(centerRenderer); + } + scrollPane.setViewportView(table1); + JList rowHeader = new JList(new AbstractListModel() { + String headers[] = { "Matin", "Midi", "Milieu A", "Fin Aprem", "Soirée"}; + + @Override + public int getSize() { + return headers.length; + } + + @Override + public Object getElementAt(int index) { + return headers[index]; + } + }); + rowHeader.setFixedCellHeight(100); + rowHeader.setFixedCellWidth(60); + scrollPane.setRowHeaderView(rowHeader); + } private void construct() { setTitle("Projection Planning"); setContentPane(mainPanel); @@ -17,6 +64,8 @@ public class GUI extends JFrame { setLocationRelativeTo(null); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.renderMenu(); + this.renderTable(); setVisible(true); } } diff --git a/src/main/java/GUI/MyTableModel.java b/src/main/java/GUI/MyTableModel.java new file mode 100644 index 0000000..a501427 --- /dev/null +++ b/src/main/java/GUI/MyTableModel.java @@ -0,0 +1,27 @@ +package GUI; + +import javax.swing.table.AbstractTableModel; + +public class MyTableModel extends AbstractTableModel { + private String[] columnNames = {"Jour 1", "Jour 2", "Jour 3", "Jour 4", "Jour 5"}; + private Object[][] data = {{"","Film 1","Film 2","",""}, {"","Film 4","","",""}, {"","","","",""}, {"","","","",""}, {"","","","",""}}; + @Override + public int getRowCount() { + return data.length; + } + + @Override + public int getColumnCount() { + return columnNames.length; + } + + @Override + public String getColumnName(int column) { + return columnNames[column]; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return data[rowIndex][columnIndex]; + } +}