//first class
class myframe2 extends JFrame
{
ImageIcon img=new ImageIcon("D:\\Mastering Java\\Java Projects\\Icons\\alert_lrg.gif ");
JLabel lbl=new JLabel(" Do You Love Computer Science?",img,JLabel.LEFT);
JPanel pnl3=new JPanel();
myframe2()
{
setupgui();
}
private void setupgui()
{
setSize(150,150);
setTitle("Error");
Container c2=getContentPane();;
pnl3.setLayout(new BorderLayout());
lbl.setIcon(img);
pnl3.add("Center",lbl);
c2.add(pnl3);
setVisible(true);
}
}
//second class
class MyInner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(!txt1.getText().equals("Name1") && !txt2.getText().equals("Name2"))
{
if (e.getActionCommand().equals("Result"))
{
//First process
int random= ((int)(50*Math.random()))+50;
txt3.setText(random+"%");
//second process
String msg[ ]={"Love Can Touch Us One Time And Last For The Life Time\nYou Are A True Lovers.","Your Feelings Are Different \nYou Should Forget it."
,"Love Is A Passion\nYou Must Be More Romantic.","You Are An Angel\n But Your Lover Is A Liar."
,"You Must Think Deeply Before That Choice\nLove Is Not An Entertainment.","Do Not Lie To Your Hart\nYou Still Love Your First Lover."
,"You Cannot Love Again\nYour First Lover is So Lovely And Cannot Be Forotten."};
ta.setText( msg[((int)( msg.length*Math.random()))] );
/* breaking up the code
double random = Math.random();
int index = (int) (msg.length*random);
String message = msg[index];
ta.setText(message);*/
ta.setForeground(Color.RED);
}
}
else
{
c2.setSelected(true);
}
}
}الخطأ هنا
c2.setSelected(true);
cannot resolve simple variable c2
كيف اصحح هذا الخطأ