我在从Jlist
选择项目并单击按钮时尝试打开一个新窗口但是我收到一条错误,指出找不到符号...我使用的是我以前表单中的相同代码我已经将我的Label设置为公共静态,因此它可以显示值,但dateInPostStatus
和postInPostStatus
中仍会出现此错误。
dateInPostStatus
和postInPostStatus
是我的标签
这是错误
cannot find symbol
symbol: variable dateInPostStatus
location: variable dateInPostStatus of type JPanel
cannot find symbol
symbol: variable postInPostStatus
location: variable postInPostStatus of type JPanel
代码:
private void commentOnPostButtonActionPerformed(java.awt.event.ActionEvent evt) {
int index = showPostStatus.getSelectedIndex();
if(index != -1)
{
String sql1 = "select * from Post where postInfo=?";
String value = (String)showPostStatus.getSelectedValue();
try
{
pst = conn.prepareStatement(sql1);
pst.setString(1,value);
rs = pst.executeQuery();
PostStatus r = new PostStatus();
String getDate= rs.getString("datePostCreated");
PostStatus.dateInPostStatus.setText(getDate);
String getPost= rs.getString("post");
PostStatus.postInPostStatus.setText(getPost);
rs.close();
pst.close();
r.setVisible(true);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
}
else
JOptionPane.showMessageDialog(null, "Select a Post to comment!");
}