Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am Working on a Project.
But I am Stuck Somewhere,
I've Created Two Frame 1st One is Main Page in Which I Put 4 jCheckBox and 1 Button I've Assign 1 Picture For Each Check Box.Like 1st Check Box Name is Happy And I've Import Happy Image in My Package.
Now I want To Do That "When I Checked Any CheckBox Like When I Checked Happy And Click My Button Than 2nd Frame Which I Have Already Created, is Automatically Appear and Shows My Happy Image On it.
I Have Created Code in My Button With IF Statement But it is Not Jumping To Another Frame. My Image is Appearing in 1st Frame.

Can Anyone Please Help Me To Do This.
That When I Checked Any of CheckBox Than 2nd Frame is Appear and Shows My Picture.
Posted
Comments
Suvendu Shekhar Giri 30-Sep-15 0:11am    
Share what you have tried so far.
Ayaz Khan 30-Sep-15 0:44am    
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here

if(jCheckBox1.isSelected()){
this.dispose();
Frame2 fm2 = new Frame2();
fm2.setSize(600,600);
fm2.setVisible(true);

jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Happy.png"))); // NOI18N
getContentPane().add(jLabel1);
jLabel1.setBounds(48, 56, 192, 200);
jLabel1.setVisible(true);
}
Ayaz Khan 30-Sep-15 0:45am    
This is The IF Conding Which I am Trying.
Ayaz Khan 30-Sep-15 0:45am    
But Image is Appearing in Same 1st Frame is Not Going To 2nd Frame.
Richard MacCutchan 30-Sep-15 4:51am    
Where is jLabel1? Also, you do realise that fm2 will disappear as soon as you return from this method as it is a local variable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900