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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
| package ci.proviande.main;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JDialog;
public class Table_Article extends JDialog {
String[] cols = {"First Name","Last Name","Sport","# of Years","Vegetarian"};//Déclaration des colonnes
Object[][] donnees = {{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},{"Alison", "Huml","Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath","Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour","Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne","Pool", new Integer(10), new Boolean(false)}};
private boolean DEBUG = false;
//JTable tab = new JTable();
//JScrollPane sp = new JScrollPane(tab);
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton Nouveau = null;
private JButton Modifier = null;
private JButton Supprimer = null;
private JButton Imprimer = null;
private JButton Close = null;
private JTable tab = null;
private JScrollPane sp = null;
/**
* @param mainFrm
*/
/**public Table_Article(Frame owner, String title, boolean modal) {
// TODO Auto-generated constructor stub
super(owner, title, modal);
initialize();
}*/
public Table_Article(MainFrm owner, String title, boolean modal) {
// TODO Auto-generated constructor stub
super(owner, title, modal);
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(600, 475);
this.setTitle("Table des articles");
this.setContentPane(getJContentPane());
this.setResizable(false);
this.setLocationRelativeTo(null);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
//JTable tbl = new JTable();
//tbl.setBounds(0, 0, 200, 200);
jContentPane = new JPanel();
jContentPane.setLayout(null);
//jContentPane.add(tbl);
jContentPane.add(getNouveau(), null);
jContentPane.add(getModifier(), null);
jContentPane.add(getSupprimer(), null);
jContentPane.add(getImprimer(), null);
jContentPane.add(getClose(), null);
jContentPane.add(getTab());
}
return jContentPane;
}
public JButton getNouveau() {
if (Nouveau == null){
Nouveau = new JButton();
Nouveau.setBounds(new Rectangle(480, 10, 100, 22));
Nouveau.setText("Nouveau");
}
return Nouveau;
}
public JButton getModifier() {
if (Modifier == null){
Modifier = new JButton();
Modifier.setBounds(new Rectangle(480, 40, 100, 22));
Modifier.setText("Modifier");
}
return Modifier;
}
public JButton getSupprimer() {
if (Supprimer == null){
Supprimer = new JButton();
Supprimer.setBounds(new Rectangle(480, 70,100,22));
Supprimer.setText("Supprimer");
}
return Supprimer;
}
public JButton getImprimer() {
if (Imprimer == null){
Imprimer = new JButton();
Imprimer.setBounds(new Rectangle(480,100,100,22));
Imprimer.setText("Imprimer");
}
return Imprimer;
}
public void setClose(JButton close) {
Close = close;
}
public JButton getClose() {
if (Close == null) {
Close = new JButton();
Close.setBounds(new Rectangle(480, 400, 100, 22));
Close.setText("Fermer");
Close.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
setVisible(false);
}
});
}
return Close;
}
public JTable getTab() {
if (tab == null){
tab = new JTable(donnees, cols);
tab.setBounds(10, 10, 450, 200);
tab.setPreferredScrollableViewportSize(new Dimension(400, 70));
tab.setFillsViewportHeight(true);
JScrollPane scrollPane = new JScrollPane(tab);
}
return tab;
}
/*public JScrollPane getSp() {
if (sp == null){
sp = new JScrollPane(){
/**
*
*/
/*private static final long serialVersionUID = 1L;
};
}
return sp;
}*/
}
// @jve:decl-index=0:visual-constraint="10,10" |
Partager