maj V1.0.1 (JDK 1.8)
This commit is contained in:
parent
6ee9fd0ce9
commit
955364ae50
@ -125,7 +125,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
|
||||
org.eclipse.jdt.core.incompleteClasspath=error
|
||||
|
Binary file not shown.
@ -1,18 +1,27 @@
|
||||
package baseUFRHG;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
public class gestionnaire extends JFrame {
|
||||
|
||||
@ -27,8 +36,10 @@ public class gestionnaire extends JFrame {
|
||||
|
||||
private JComboBox<String> cYears;
|
||||
private JComboBox<String> cFormations;
|
||||
private JComboBox<String> cGroupeTD;
|
||||
private JTable table;
|
||||
private JScrollPane scrollPane_1;
|
||||
private JLabel lblNewLabel;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
@ -59,21 +70,32 @@ public class gestionnaire extends JFrame {
|
||||
|
||||
nBase = recupeBases.recupeLaBase();
|
||||
cYears = new JComboBox<String>();
|
||||
cYears.setLocation(10, 25);
|
||||
cYears.setSize(168, 32);
|
||||
cFormations = new JComboBox<String>();
|
||||
cFormations.setSize(289, 32);
|
||||
cFormations.setLocation(188, 25);
|
||||
cGroupeTD = new JComboBox<String>();
|
||||
cGroupeTD.setBounds(485, 25, 180, 32);
|
||||
|
||||
|
||||
table = new JTable();
|
||||
table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
|
||||
List<String> lGroupeTD = new ArrayList<String>();
|
||||
for(noeud nChild : nBase.getChildren()) {
|
||||
cYears.addItem(nChild.getName());
|
||||
for(noeud nFormation : nChild.getChildren()) {
|
||||
cFormations.addItem(nFormation.getName());
|
||||
String GroupeTD = nFormation.getAttributes().get("Groupe_TD");
|
||||
if(GroupeTD!=null) if(!GroupeTD.isEmpty()) {
|
||||
if(!lGroupeTD.contains(GroupeTD))lGroupeTD.add(GroupeTD);
|
||||
}
|
||||
}
|
||||
}
|
||||
cYears.setBounds(10, 25, 157, 22);
|
||||
|
||||
cYears.setVisible(true);
|
||||
cFormations.setBounds(210, 25, 307, 22);
|
||||
cFormations.setVisible(true);
|
||||
|
||||
// Ajout d'un ActionListener à la JComboBox
|
||||
@ -84,27 +106,48 @@ public class gestionnaire extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
table.setBounds(38, 136, 496, 199);
|
||||
// scrollPane.add(table);
|
||||
// Désactiver l'ajustement automatique des colonnes
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
|
||||
contentPane.setLayout(null);
|
||||
contentPane.add(cYears);
|
||||
contentPane.add(cFormations);
|
||||
// contentPane.add(table);
|
||||
|
||||
|
||||
scrollPane_1 = new JScrollPane();
|
||||
scrollPane_1.setViewportBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
scrollPane_1.setBounds(10, 71, 1164, 515);
|
||||
|
||||
contentPane.add(scrollPane_1);
|
||||
scrollPane_1.setViewportView(table);
|
||||
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
contentPane.add(panel, BorderLayout.NORTH);
|
||||
panel.setLayout(null);
|
||||
panel.setPreferredSize(new Dimension(400, 80));
|
||||
panel.setBackground(Color.gray);
|
||||
panel.add(cYears);
|
||||
panel.add(cFormations);
|
||||
|
||||
JLabel lblYears = new JLabel("Année");
|
||||
lblYears.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||
lblYears.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
lblYears.setBounds(10, 11, 72, 14);
|
||||
panel.add(lblYears);
|
||||
|
||||
JLabel lblFormation = new JLabel("Formation");
|
||||
lblFormation.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||
lblFormation.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
lblFormation.setBounds(188, 11, 101, 14);
|
||||
panel.add(lblFormation);
|
||||
|
||||
lblNewLabel = new JLabel("Groupe TD");
|
||||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||
lblNewLabel.setBounds(489, 11, 121, 14);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
|
||||
panel.add(cGroupeTD);
|
||||
|
||||
majTable();
|
||||
|
||||
@ -129,8 +172,12 @@ public class gestionnaire extends JFrame {
|
||||
String key = entry.getKey();
|
||||
head[indexCol] = key;
|
||||
}else {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
data[indexRow-1][indexCol] = value;
|
||||
if(key.equals("Groupe_TD")) {
|
||||
|
||||
}
|
||||
}
|
||||
indexCol++;
|
||||
}
|
||||
@ -138,25 +185,13 @@ public class gestionnaire extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
table.setModel(new DefaultTableModel(data, head));
|
||||
|
||||
|
||||
|
||||
|
||||
for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
|
||||
// Obtention de la colonne à l'index donné
|
||||
table.getColumnModel().getColumn(columnIndex).setWidth(100);
|
||||
// column.setHeaderValue(head[columnIndex]);
|
||||
// Ajustement de la largeur préférée de la colonne
|
||||
// column.setWidth(300);
|
||||
table.getColumnModel().getColumn(columnIndex).setWidth(getMaxColumnWidth(table, columnIndex));
|
||||
}
|
||||
|
||||
|
||||
|
||||
table.revalidate();
|
||||
table.repaint();
|
||||
|
||||
@ -166,28 +201,28 @@ public class gestionnaire extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Détermine la largeur de la colonne max pour ajustement.
|
||||
* @param table
|
||||
* @param columnIndex
|
||||
* @return
|
||||
*/
|
||||
private static int getMaxColumnWidth(JTable table, int columnIndex) {
|
||||
int maxWidth = 40;
|
||||
|
||||
// private static int getMaxColumnWidth(JTable table, int columnIndex) {
|
||||
// int maxWidth = 200;
|
||||
//// TableColumn column = table.getColumnModel().getColumn(columnIndex);
|
||||
// // Obtention du modèle de rendu de cellules par défaut
|
||||
// DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
|
||||
//
|
||||
// if(cellRenderer!=null) {
|
||||
// for (int row = 0; row < table.getRowCount(); row++) {
|
||||
// Component cellComponent = cellRenderer.getTableCellRendererComponent(table,
|
||||
// table.getValueAt(row, columnIndex),
|
||||
// false, false, row, columnIndex);
|
||||
//
|
||||
// maxWidth = Math.max(maxWidth, cellComponent.getPreferredSize().width);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return maxWidth;
|
||||
// }
|
||||
DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
|
||||
|
||||
|
||||
if(cellRenderer!=null) {
|
||||
for (int row = 0; row < table.getRowCount(); row++) {
|
||||
Component cellComponent = cellRenderer.getTableCellRendererComponent(table,
|
||||
table.getValueAt(row, columnIndex),
|
||||
false, false, row, columnIndex);
|
||||
|
||||
maxWidth = Math.max(maxWidth, cellComponent.getPreferredSize().width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return maxWidth;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user