JPanel doesn't refresh
Hello!
i have created a JDialog that has a JPanel. this JPanel has a list that's frequently updated.
Now, when i first started coding, i used J2RE 1.4.2 -->The JDialog and its JPanel worked perfectly!!!
I switched to JDK 1.5 and there were problems!!!
here is my code that worked with J2RE 1.4.2, why doesn't it work with JDK 1.5?
...
private JPanel listPanel =new JPanel();
...
privatevoid createJDialogBox()
{
boxDialog =new JDialog();
boxDialog.getContentPane().setLayout(new BorderLayout());
boxDialog.addWindowListener(this);
dialogCancelButton =new JButton();
dialogCancelButton.setFont(new Font(constVar.getButtonFont(), constVar.getButtonFontStyle(), constVar.getButtonFontSize()));
dialogOkButton =new JButton();
dialogOkButton.setFont(new Font(constVar.getButtonFont(), constVar.getButtonFontStyle(), constVar.getButtonFontSize()));
goToPanel =new JPanel();
goToPanel.setLayout(new BorderLayout());
goToPanel.setPreferredSize(new java.awt.Dimension(149, 31));
titlePanel =new JPanel();
titlePanel.setBorder(new EtchedBorder());
goToLabel =new JLabel();
goToLabel.setFont(new Font(constVar.getLabelFont(), constVar.getLabelFontStyle(), constVar.getLabelFontSize()));
goToLabel.setHorizontalAlignment(SwingConstants.CENTER);
goToTextField =new JTextField();
goToTextField.setPreferredSize(new java.awt.Dimension(10, 20));
goToTextField.setFont(new Font(constVar.getTextFieldFont(), constVar.getTextFieldFontStyle(), constVar.getTextFieldFontSize()));
southPanel =new JPanel(new GridLayout(2, 2));
// pour le label de Go To
goToString = anAction.getLabel(languageNumber,"BD_GO_TO");
// pour le label de Cancel
dialogCancelButton.setText(anAction.getLabel(languageNumber,"CANCEL"));
// pour le label de Ok
dialogOkButton.setText(anAction.getLabel(languageNumber,"OK"));
goToLabel.setText(goToString);
southPanel.add(goToLabel);
southPanel.add(goToTextField);
dialogOkButton.addMouseListener(new MouseAdapter()
{
publicvoid mouseClicked(MouseEvent evt)
{
dialogOkButtonMouseClicked(evt);
}
});
dialogCancelButton.addMouseListener(new MouseAdapter()
{
publicvoid mouseClicked(MouseEvent evt)
{
dialogCancelButtonMouseClicked(evt, boxDialog);
}
});
southPanel.add(dialogOkButton);
southPanel.add(dialogCancelButton);
boxDialog.getContentPane().add(southPanel, BorderLayout.SOUTH);
boxDialog.setSize(new Dimension(500,300));
boxDialog.setLocationRelativeTo(generalPanel);
}
...
//somewhere in the constructor i call createJDialogBox();
...
//this is where i update the JPanel with a specific list
//the other functions that share the same JDialog have the same implementation: a list is created and added to the JPanel
publicvoid mpnItemActionPerformed(Connection conn, ActionEvent e,int languageNumber, JPanel generalPanel, JPanel listPanel, JDialog boxDialog, List mpnSearchList)
{
int product = getProductNumber();
setLanguageNumber(languageNumber);
try
{
if (product == -1)// on n'a pas selectionne de produit particulier, donc on affiche tout
{
stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet result = stat.executeQuery("Select SQL From ICM_SQL Where ID = 55");
while (result.next())
{
sql = result.getString("SQL");
}
result = stat.executeQuery(sql);
while (result.next())
{
String item ="", firstMPN ="", secondMPN ="";
firstMPN = result.getString(1);
secondMPN = result.getString(2);
if (firstMPN.compareTo(secondMPN) == 0)// si les 2 sont
// pareils, n'afficher
// que le 1er
{
item = item + firstMPN;
}
else
// afficher le 2eme
{
item = item + secondMPN;
}
mpnSearchList.add(item);// remplir la liste
}
}
else
{
stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String[] variablesArray =new String[2];
variablesArray[0] ="" + product;
variablesArray[1] ="" + product;
ResultSet result = stat.executeQuery("Select SQL From ICM_SQL Where ID = 12");
while (result.next())
{
sql = result.getString("SQL");
}
sql = addVariables(sql, variablesArray);
result = stat.executeQuery(sql);
while (result.next())
{
String item ="", firstMPN ="", secondMPN ="";
firstMPN = result.getString(1);
secondMPN = result.getString(2);
if (firstMPN.compareTo(secondMPN) == 0)// si les 2 sont
// pareils, n'afficher
// que le 1er
{
item = item + firstMPN;
}
else
// afficher le 2eme
{
item = item + secondMPN;
}
mpnSearchList.add(item);// remplir la liste
}
}
for(int i =0;i<mpnSearchList.getItemCount();i++)
{
System.out.println(mpnSearchList.getItem(i));
}
listPanel =new JPanel();
listPanel.setLayout(new BorderLayout());
mpnSearchList.setFont(new java.awt.Font("Arial", 0, 12));
listPanel.add(mpnSearchList, BorderLayout.CENTER);
boxDialog.getContentPane().add(listPanel, BorderLayout.CENTER);
}catch(SQLException exc)
{
System.out.println("Error in mpnItemActionPerformed - SQL Exception");
}
//boxDialog.setModal(true);
boxDialog.setVisible(true);
}
please help me.
Thanks>

