Drop_of_Rain
asked on
This came as a solution for a jlabel on top of the jpanel
It didn't work a method cll from nowhere I guess! HELP
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MyClass4 extends JPanel {
JLabel jLabel1;
ArrayList myArrayList = new ArrayList();
public MyClass4() {
// Call it like this . . .
jLabel = JLabel();
setLayout(new GridLayout(0,3)); // Setting MY layout...
add(jLabel1);
jLabel1.setText("Defensive Moves");
setBackground(Color.white) ;
looprow:
for (int row=0; row<20; row++) {
for(int col=0; col<3; col++) {
int n=(20*col+row+1);
if (n>50) break looprow;
JCheckBox check = new JCheckBox("" + n);
myArrayList.add(check);
add(check);
}
}
}
}
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MyClass4 extends JPanel {
JLabel jLabel1;
ArrayList myArrayList = new ArrayList();
public MyClass4() {
// Call it like this . . .
jLabel = JLabel();
setLayout(new GridLayout(0,3)); // Setting MY layout...
add(jLabel1);
jLabel1.setText("Defensive
setBackground(Color.white)
looprow:
for (int row=0; row<20; row++) {
for(int col=0; col<3; col++) {
int n=(20*col+row+1);
if (n>50) break looprow;
JCheckBox check = new JCheckBox("" + n);
myArrayList.add(check);
add(check);
}
}
}
}
I didnt get the question can you clarify it ?
ASKER
error message can't resolve method jLabel = JLabel();
It is because it should be like :
jLabel = new JLabel();
here it is :
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MyClass4 extends JPanel {
JLabel jLabel1;
ArrayList myArrayList = new ArrayList();
public MyClass4() {
// Call it like this . . .
jLabel = new JLabel();
setLayout(new GridLayout(0,3)); // Setting MY layout...
add(jLabel1);
jLabel1.setText("Defensive Moves");
setBackground(Color.white) ;
looprow:
for (int row=0; row<20; row++) {
for(int col=0; col<3; col++) {
int n=(20*col+row+1);
if (n>50) break looprow;
JCheckBox check = new JCheckBox("" + n);
myArrayList.add(check);
add(check);
}
}
}
}
jLabel = new JLabel();
here it is :
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MyClass4 extends JPanel {
JLabel jLabel1;
ArrayList myArrayList = new ArrayList();
public MyClass4() {
// Call it like this . . .
jLabel = new JLabel();
setLayout(new GridLayout(0,3)); // Setting MY layout...
add(jLabel1);
jLabel1.setText("Defensive
setBackground(Color.white)
looprow:
for (int row=0; row<20; row++) {
for(int col=0; col<3; col++) {
int n=(20*col+row+1);
if (n>50) break looprow;
JCheckBox check = new JCheckBox("" + n);
myArrayList.add(check);
add(check);
}
}
}
}
you're also mixing names, jLabel and jLabel1.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.