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
| import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.*;
import java.awt.geom.AffineTransform;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.text.*;
class FenetreDonnees extends JFrame
{
private JPanel pan_back = new JPanel();
private JPanel pan_back_haut = new JPanel();
private JPanel pan_back_haut_coupe = new JPanel();
private JPanel pan_back_bas = new JPanel();
private JPanel pan_consommation = new JPanel();
private JScrollPane scp_consommation = new JScrollPane();
private JPanel pan_benefices = new JPanel();
private JPanel pan_stocks = new JPanel();
private JPanel pan_buttons = new JPanel();
//private JLabel [] lb_ressources_scroll;
//private JLabel [] lb_benefices_scroll;
//private JTextField [][] jtf_consommation_scroll;
private JLabel lb_infos = new JLabel("Remplissez les zones de texte, puis cliquez sur valider.");
private JButton bt_valider = new JButton("Valider");
private JButton bt_reset = new JButton("Reset");
private int nb_produits;
private int nb_ressources;
private JTable table_consommation;
private Object[][] data_consommation;
private JTable table_stocks;
private Object[][] data_stocks;
private JTable table_benefices;
private Object[][] data_benefices;
private JOptionPane question;
FenetreDonnees(int nb_produits,int nb_ressources)
{
System.out.println(nb_produits);
System.out.println(nb_ressources);
setTitle("Insertion des donnees");
//initialisation du dictionnaire
//jtf_consommation_scroll = new JTextField [nb_produits][nb_ressources];
//GridLayout dico = new GridLayout(nb_ressources+1,nb_produits+1);
//GridLayout dico = new GridLayout(5,5);
//scp_consommation.setLayout(dico);
//scp_consommation.setLayout(new GridLayout(nb_produits,nb_ressources));
//scp_consommation.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
/*
for(int y=1;y<=nb_ressources;y++)
{
for(int x=1;x<=nb_produits;x++)
{
scp_consommation.add(jtf_consommation_scroll[x][y]);
}
}*/
//mise en place des grilles
pan_back.setLayout(new BorderLayout());
pan_back_haut.setLayout(new BorderLayout());
pan_back_bas.setLayout(new BorderLayout());
pan_consommation.setLayout(new BorderLayout());
pan_benefices.setLayout(new BorderLayout());
pan_stocks.setLayout(new BorderLayout());
pan_buttons.setLayout(new BorderLayout());
pan_back_haut_coupe.setLayout(new BorderLayout());
pan_back.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
pan_back_haut.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
pan_back_bas.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
pan_consommation.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Consommations : "), BorderFactory.createEmptyBorder(5,5,5,5)));
pan_benefices.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Benefices des produit : "), BorderFactory.createEmptyBorder(5,5,5,5)));
pan_stocks.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Stocks des ressource : "), BorderFactory.createEmptyBorder(5,5,5,5)));
data_consommation = new Object[nb_ressources][nb_produits];
table_consommation = new JTable(nb_ressources+1,nb_produits+1);
for(int x=1;x<=nb_produits;x++)
{
table_consommation.setValueAt("Pr. "+x,0,x);
}
for(int y=1;y<=nb_ressources;y++)
{
table_consommation.setValueAt("Re. "+y,y,0);
}
data_stocks = new Object[nb_ressources][2];
table_stocks = new JTable(nb_ressources,2);
for(int y=0;y<=nb_ressources-1;y++)
{
table_stocks.setValueAt("St. Re. "+y,y,0);
}
data_benefices = new Object[nb_produits][2];
table_benefices = new JTable(nb_produits,2);
for(int x=0;x<=nb_produits-1;x++)
{
table_benefices.setValueAt("Be. Pro. "+x,x,0);
}
pan_consommation.add(table_consommation,BorderLayout.CENTER);
pan_stocks.add(table_stocks,BorderLayout.CENTER);
pan_benefices.add(table_benefices,BorderLayout.CENTER);
pan_back_haut_coupe.add(pan_benefices,BorderLayout.EAST);
pan_back_haut_coupe.add(pan_stocks,BorderLayout.WEST);
pan_back.add(lb_infos,BorderLayout.NORTH);
pan_back_haut.add(pan_consommation,BorderLayout.NORTH);
pan_back_haut.add(pan_back_haut_coupe,BorderLayout.CENTER);
pan_buttons.add(bt_valider,BorderLayout.WEST);
pan_buttons.add(bt_reset,BorderLayout.EAST);
pan_back_bas.add(pan_buttons,BorderLayout.CENTER);
pan_back.add(pan_back_haut,BorderLayout.CENTER);
pan_back.add(pan_back_bas,BorderLayout.SOUTH);
setSize(400,542);
setContentPane(pan_back);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
bt_reset.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
question = new JOptionPane();
if(JOptionPane.showConfirmDialog(null,"Etes vous sur ?", "Attention", JOptionPane.YES_NO_OPTION)==0)
{
for(int x=1;x<=nb_produits;x++)
{
for(int y=1;y<=nb_ressources;y++)
{
table_consommation.setValueAt("",y,x);
}
}
for(int y=0;y<=nb_ressources-1;y++)
{
table_stocks.setValueAt("",y,1);
}
for(int x=0;x<=nb_produits-1;x++)
{
table_benefices.setValueAt("",x,1);
}
}
} });
}
} |
Partager