Jscrollpanel + un panel dans un panel
Bonjour, je vous explique mon soucis :
J'ai deux classes qui dans la 1ière créer un MainPanel ou je créer donc une fenêtre avec des boutons et des label, puis je veut ajouter des élements du type de ma deuxième classe.J'ai donc tous stocker dans un vector et j'essaye donc de rajouter ses élements a mon premier panel et c'est la que ça coince.
Puis dans mon premier panel je voulais rajouter un JScrollpanel mais la il ne s'affiche même pas :)
Code classe 1
Code:
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
| public class IhmCalibration extends JDialog {
private static JLabel unitLabel = null;
private static JLabel calibrationLabel = null;
private static JButton Submit = null;
private static JButton Cancel = null;
private static JDialog frame = null;
private static Vector <IhmLinesCalibration> Lines = new Vector <IhmLinesCalibration>();
/** Panel that contains all lanes panels */
private static JPanel lanesContainer;
private static int lanesNumber = 8;
static void createAndShowGUI() {
frame = new JDialog();
frame.setSize(650, 550);
frame.setResizable(false);
frame.setModal(true);
frame.setContentPane(getPanel());
frame.setVisible(true);
}
/*
* Create a panel
*/
public static JPanel getPanel(){
JPanel jContentPane = new JPanel();
jContentPane.setBackground(new Color(71, 145, 203)); //Background Color
unitLabel = new JLabel();
unitLabel.setBounds(new Rectangle(110, 15, 98, 19));
unitLabel.setText("Unité ");
calibrationLabel = new JLabel();
calibrationLabel.setBounds(new Rectangle(230, 15, 98, 19));
calibrationLabel.setText("Etalonnage ");
lanesContainer = new JPanel(new BorderLayout(8,1));
lanesContainer.setSize(frame.getWidth(), frame.getHeight());
/*
* Add element in Lines vector
*/
for (int i=0;i<10;i++)
{
Lines.addElement(new IhmLinesCalibration() );
}
lanesContainer.setLayout(null);
/*
* Add vector element in lanesContainer
*/
for(int i = 0; i < 9; i++){
lanesContainer.add(Lines.get(i));
}
lanesContainer.setVisible(true);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(lanesContainer,v,h);
jsp.setPreferredSize(new Dimension(200,25*lanesNumber));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setBackground(new Color(71, 145, 203));
jContentPane.add(unitLabel, null);
jContentPane.add(calibrationLabel, null);
jContentPane.add(getAnnuler(), null);
jContentPane.add(getValider(), null);
jContentPane.add(lanesContainer,null);
jContentPane.add(jsp);
return jContentPane;
} |
Code classe 2
Code:
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
| public class IhmLinesCalibration extends JPanel{
private static JLabel channel;
private static JComboBox chan;
private static JButton submitLines =null;
private static JComboBox unit = null;
public static JLabel functionField = null;
public IhmLinesCalibration(){
super();
this.getPanel();
}
public static JPanel getPanel(){
JPanel jContentPane = new JPanel();
channel = new JLabel();
channel.setBounds(new Rectangle(25, 45, 20, 60));
channel.setText("Voie :");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(channel, null);
jContentPane.add(getChoisechan() ,null);
jContentPane.add(getSubmitchan() ,null);
jContentPane.add(getChoiseUnit(), null);
jContentPane.add(getFunctionField(), null);
jContentPane.setVisible(true);
jContentPane.setBackground(new Color(255,255,255));
return jContentPane;
} |
Si quelqu'un a une idée merci,
Cordialement